~hristoast/hristoast

hristoast/site/control-the-dotfiles.html -rw-r--r-- 5.0 KiB View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<h1 id="title">Control the dotfiles!</h1>

<div id="dates">
  <span>Posted: <time id="post-date">2015-08-30</time> | Updated: <time>2019-11-09</time></span>
</div>

<p>When I was first learning to use GNU/Linux and scripting, I was dead set on creating the bestest backup script. You see, during this period I would very frequently hop distros and I wanted an easy way to restore various settings I wanted. I had never really used any kind of version control system, so methodical usage of <code>tar</code> seemed like the logical choice. Even if it wasn&#39;t the best solution, I was trying to do what I could to get the most out of my experience working and playing within this ecosystem. I wanted to shape it as close to exactly what I wanted as possible, and maybe along the way find out new things to try and add to the mix.</p>

<p>It wasn&#39;t until a few years later that I was able to implement a system for achieving exactly what I was trying to do with a backups script but without making any traditional backups at all.</p>

<p>Using a so-called &#39;dotfiles repo&#39; is a pretty common practice. When I was first exposed to the idea I remember thinking &quot;that&#39;s neat, I should try something like that out&quot; but didn&#39;t really jump on it. now it&#39;s not only how I deploy my crap (files, scripts, etc.) but also how I track and &quot;back it up&quot;. A dotfiles repo, combined with a way to manage it&#39;s state on your system, can be a powerful way to keep your system configured the way you want it while still being simple to maintain.</p>

<p>My system consists of a few components:</p>

<ul>
  <li>A directory tree of roughly the following structure to accomadate setups for multiple machines:</li>
</ul>

<pre><code>src/toasty-dotfiles
├── alucard
│&nbsp;&nbsp; ├── bin
│&nbsp;&nbsp; ├── etc
│   ├── games
│&nbsp;&nbsp; ├── install_all_configs.sh
│&nbsp;&nbsp; └── setup_alucard.sh
├── richter
│&nbsp;&nbsp; ├── bin
│&nbsp;&nbsp; ├── etc
│&nbsp;&nbsp; ├── install_all_configs.sh
│&nbsp;&nbsp; └── setup_richter.sh
└── soma
    ├── bin
    ├── desktops
    ├── etc
    ├── games
    ├── hosts
    ├── install_all_dotfiles.sh
    └── setup_soma.sh</code></pre>

<ul>
	<li>A bunch of symlinks throughout my home directory pointing back here to various things</li>
	<li>Using git (or any other vcs) to version control all of it</li>
</ul>

<p>There are two shell scripts at play on each machine; one for configuring files in my home directory, and one for taking care of system things after a new install. The new install setup script doesn&#39;t do anything crazier than using the package maneger to install desired packages, but it does also backup and and replace a few files under <code>/etc</code> with versions from my repo.</p>

<p>That first file, <code>install_all_dotfiles.sh</code>, contains a list of scripts (under <code>bin</code>) that it needs to make symlinks to. The list is laid out like this:</p>

<pre><code>.bashrc
       bin/aliens-vs-predator-2000
       bin/banished
       bin/daggerfall
       bin/diablo2
       bin/doom3
       bin/duke-server
       bin/duke3d
       bin/dukedc
       bin/dukenwinter
       bin/dukevacation
       bin/dungeon-keeper
       bin/dungeon-keeper2
       bin/dwarf-fortress
       bin/gta-san-andreas
       bin/higan
       bin/martian-dreams
       bin/minecraft
       bin/morrowind
       bin/morrowind-launcher
       bin/pcsx
       bin/ppsspp
       bin/rcr-dos
       bin/sim-city-2000
       bin/ultima6
       bin/ultima7-forge-of-virtue
       bin/ultima7-serpent-isle-silver-seed
       bin/unreal-tournament-goty
       bin/warcraft2
       bin/winsteam
       bin/winsteamwinecfg
       .config/openbox/autostart
       .config/openbox/rc.xml
       .config/openbox/menu.xml
       .config/openmw/openmw.cfg
       .config/openmw/settings.cfg
       .config/tint2/tintwizard.conf
       .config/tint2/tint2rc
       .conkyrc
       .emacs.d/init.el
       .exult.cfg
       games/daggerfall.conf
       games/dungeon_keeper.conf
       games/earthworm_jim.conf
       games/earthworm_jim2.conf
       games/martian_dreams.conf
       games/rcr.conf
       games/sim_city_2k.conf
       games/u6.conf
       games/warcraft2.conf
       .nuvierc
       .oh-my-zsh/custom/mine.zsh
       .oh-my-zsh/themes/larry34.zsh-theme
       .ssh/config
       .vimrc
       .zshrc</code></pre>

<p>The rest of the script consists of three simple bash functions: one to ensure a specific working directory, one to check for (and remove) existing symlinks or rename existing real files, and another to &quot;install&quot; the symlinks to my version-controlled scripts.</p>

<p>If I add a new script, I just add it to my list and run the installer. Simple as that I&#39;ve got launchers for various things and fine-grained control over them.</p>

<p>You don&#39;t have to do it exactly the way I do, but I think that some kind of &quot;dotfiles&quot; repo is a great idea for managing your setup.</p>