-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdotfiles.html
More file actions
164 lines (148 loc) · 7.95 KB
/
dotfiles.html
File metadata and controls
164 lines (148 loc) · 7.95 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Managing my dotfiles as a git repository</title>
<link rel="alternate" type="application/rss+xml" title="RSS" href="https://drewdevault.com/blog/index.xml">
<link rel="icon" type="image/png" href="/avatar.png">
<link rel="stylesheet" href="/main.min.fbee2ede33c02698d508178167c7556879b09625f70dfe0d8fa551c74788392f.css">
</head>
<h1>
Managing my dotfiles as a git repository
<small>
<span class="date">December 30, 2019</span>
on
<span class="site"><a href="https://drewdevault.com/">Drew DeVault's blog</a></span>
</small>
</h1>
<main>
<article>
<p>There are many tools for managing your dotfiles - user-specific configuration
files. GNU stow is an example. I’ve tried a few solutions over the years, but I
settled on a very simple system several years ago which has served me very well
in the time since: my $HOME is a git repository. <a href="https://git.sr.ht/~sircmpwn/dotfiles">This
repository</a>, in fact. This isn’t an
original idea, but I’m not sure where I first heard it from either, and I’ve
extended upon it somewhat since.</p>
<p>The key to making this work well is my one-byte <code>.gitignore</code> file:</p>
<pre><code>*
</code></pre><p>With this line, and git will ignore all of the files in my $HOME directory, so I
needn’t worry about leaving personal files, music, videos, other git
repositories, and so on, in my public dotfiles repo. But, in order to track
anything at all, we need to override the gitignore file on a case-by-case basis
with <code>git add -f</code>, or <code>--force</code>. To add my vimrc, I used the following command:</p>
<pre><code>git add -f .vimrc
</code></pre><p>Then I can commit and push normally, and .vimrc is tracked by git. The gitignore
file does not apply to any files which are already being tracked by git, so any
future changes to my vimrc show up in git status, git diff, etc, and can be
easilly committed with <code>git commit -a</code>, or added to the staging area normally
with <code>git add</code> — using <code>-f</code> is no longer necessary. Setting up a new
machine is quite easy. After the installation, I run the following commands:</p>
<pre><code>cd ~
git init
git remote add origin git@git.sr.ht:~sircmpwn/dotfiles
git fetch
git checkout -f master
</code></pre><p>A quick log-out and back in and I feel right at $HOME. Additionally, I have
configured $HOME as a prefix, so that ~/bin is full of binaries, ~/lib has
libraries, and so on; though I continue to use ~/.config rather than ~/etc. I
put $HOME/bin ahead of anything else in my path, which allows me to shadow
system programs with wrapper scripts as necessary. For example, ~/bin/xdg-open
is as follows:</p>
<div class="highlight"><pre class="chroma"><code class="language-sh" data-lang="sh"><span class="cp">#!/bin/sh
</span><span class="cp"></span><span class="k">case</span> <span class="s2">"</span><span class="si">${</span><span class="nv">1</span><span class="p">%%:*</span><span class="si">}</span><span class="s2">"</span> in
http<span class="p">|</span>https<span class="p">|</span>*.pdf<span class="o">)</span>
<span class="nb">exec</span> qutebrowser <span class="s2">"</span><span class="nv">$1</span><span class="s2">"</span>
<span class="p">;;</span>
mailto<span class="o">)</span>
<span class="nb">exec</span> aerc <span class="s2">"</span><span class="nv">$1</span><span class="s2">"</span>
<span class="p">;;</span>
*<span class="o">)</span>
<span class="nb">exec</span> /usr/bin/xdg-open <span class="s2">"</span><span class="nv">$@</span><span class="s2">"</span>
<span class="p">;;</span>
<span class="k">esac</span>
</code></pre></div><p>Replacing the needlessly annoying-to-customize xdg-open with one that just
does what I want, falling back to /usr/bin/xdg-open if necessary. Many other
non-shadowed scripts and programs are found in ~/bin as well.</p>
<p>However, not all of my computers are configured equally. Some run different
Linux (or non-Linux) distributions, or have different concerns being desktops,
servers, laptops, phones, etc. It’s often useful for this reason to be able to
customize my configuration for each host. For example, before $HOME/bin in my
$PATH, I have $HOME/bin/$(hostname). I also run several machines on
different architectures, so I include $HOME/bin/$(uname -m)<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup> as well. To
customize my sway configuration to consider the different device configurations
of each host, I use the following directive in ~/.config/sway/config:</p>
<pre><code>include ~/.config/sway/`hostname`
</code></pre><p>Then I have a host-specific configuration there, also tracked by git so I can
conveniently update one machine from another. I take a similar approach to
per-host configuration for many other pieces of software I use.</p>
<p>Rather than using (and learning) any specialized tools, I find my needs quite
adequately satisfied by a simple composition of several Unix primitives with a
tool I’m already very familiar with: git. Version controlling your configuration
files is a desirable trait even with other systems, so why not ditch the
middleman?</p>
<section class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1" role="doc-endnote">
<p><code>uname -m</code> prints out the system architecture. Try it for yourself, I bet it’ll read “x86_64” or maybe “aarch64”. <a href="#fnref:1" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
</ol>
</section>
</article>
</main>
<section class="webring">
<h2>
Articles from blogs I read
<small class="attribution">
Generated by
<a href="https://git.sr.ht/~sircmpwn/openring">openring</a>
</small>
</h2>
<section class="articles">
<div class="article">
<h4 class="title">
<a href="https://go.dev/blog/go1.21rc" target="_blank" rel="noopener">Go 1.21 Release Candidate</a>
</h4>
<p class="summary">Go 1.21 RC brings language improvements, new standard library packages, PGO GA, backward and forward compatibility in the toolchain and faster builds.</p>
<small class="source">
via <a href="https://blog.golang.org/feed.atom">The Go Blog</a>
</small>
<small class="date">June 21, 2023</small>
</div>
<div class="article">
<h4 class="title">
<a href="https://emersion.fr/blog/2023/status-update-54/" target="_blank" rel="noopener">Status update, June 2023</a>
</h4>
<p class="summary">Hi!
This month Rose Hudson has started working on wlroots as part of Google Summer
of Code! She will focus on reducing frame latency by implementing an adaptive
frame scheduler. She already has landed new wlroots APIs to
measure render time. You can follow Ro…</p>
<small class="source">
via <a href="https://emersion.fr/blog/">emersion</a>
</small>
<small class="date">June 15, 2023</small>
</div>
<div class="article">
<h4 class="title">
<a href="https://100r.co/site/log.html#may2023" target="_blank" rel="noopener">Summary of changes for May 2023</a>
</h4>
<p class="summary">
Hey everyone! This is the list of all the changes we've done to our projects and apps during the month of May. We'll also be reporting in our on position in the world, and on our future plans.
Summary Of Changes
100r.co, updated {jib_cars} (2023.0…</p>
<small class="source">
via <a href="https://100r.co">Hundred Rabbits</a>
</small>
<small class="date">May 1, 2023</small>
</div>
</section>
</section>
<footer>
The content for this site is
<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>.
The <a href="https://git.sr.ht/~sircmpwn/drewdevault.com">code for this site</a>
is <a href="https://opensource.org/licenses/MIT">MIT</a>.
</footer>