aboutsummaryrefslogtreecommitdiff
path: root/docs/index.xml
diff options
context:
space:
mode:
Diffstat (limited to 'docs/index.xml')
-rw-r--r--docs/index.xml184
1 files changed, 184 insertions, 0 deletions
diff --git a/docs/index.xml b/docs/index.xml
index 62c8871..5586abd 100644
--- a/docs/index.xml
+++ b/docs/index.xml
@@ -12,6 +12,190 @@
12 <language>en-us</language> 12 <language>en-us</language>
13 <copyright>Creative Commons BY-NC-SA 4.0</copyright> 13 <copyright>Creative Commons BY-NC-SA 4.0</copyright>
14 <item> 14 <item>
15<title>Curing A Case Of Git-UX</title>
16<description>&lt;p&gt;Git worktrees are great, but they fall behind the venerable &lt;code&gt;git checkout&lt;/code&gt; sometimes. I attempted to fix that with &lt;a href="https://github.com/junegunn/fzf"&gt;fzf&lt;/a&gt; and a bit of bash.&lt;/p&gt;
17&lt;p&gt;&lt;a href="https://asciinema.org/a/D297ztKRzpE4gAHbPTPmkqYps"&gt;&lt;img src="https://asciinema.org/a/D297ztKRzpE4gAHbPTPmkqYps.svg" /&gt;&lt;/a&gt;&lt;/p&gt;
18&lt;p&gt;Fear not if you haven’t heard of “worktrees”, I have included a primer here.&lt;br /&gt;
19&lt;a href="#what-makes-them-clunky"&gt;Skip the primer -&amp;gt;&lt;/a&gt;.&lt;/p&gt;
20&lt;h3 id="why-worktrees"&gt;Why Worktrees?&lt;/h3&gt;
21&lt;p&gt;Picture this. You are whacking away on a feature branch. Halfway there, in fact. Your friend asks you fix something urgently. You proceed to do one of three things:&lt;/p&gt;
22&lt;ul&gt;
23&lt;li&gt;create a temporary branch, make a WIP commit, begin working on the fix&lt;/li&gt;
24&lt;li&gt;stash away your changes, begin working on the fix&lt;/li&gt;
25&lt;li&gt;unfriend said friend for disturbing your flow&lt;/li&gt;
26&lt;/ul&gt;
27&lt;p&gt;All of these options are … subpar. With the temporary branch, you are forced to create a partial, non-working commit, and then reset said commit once done with the fix. With the stash approach, you are required to now keep a mental model of the stash, be aware of untracked files that don’t get stashed by default, etc. Why won’t git just let you work on two things at the same time without &lt;em&gt;thinking&lt;/em&gt; so much?&lt;/p&gt;
28&lt;p&gt;That is exactly what worktrees let you do. Worktrees let you have more than one checkout at a time, each checkout in a separate directory. Like creating a new clone, but safer (it disallows checking out the same branch twice) and a lot more space efficient (the new working tree is “linked” to the “main” worktree, and a good amount of stuff is shared). When your friend asks you to make the fix, you proceed like so:&lt;/p&gt;
29&lt;ol type="1"&gt;
30&lt;li&gt;Create a new working tree with:&lt;/li&gt;
31&lt;/ol&gt;
32&lt;div class="sourceCode" id="cb1"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb1-1"&gt;&lt;a href="#cb1-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# git worktree add -b &amp;lt;branch-name&amp;gt; &amp;lt;path&amp;gt; &amp;lt;from&amp;gt;&lt;/span&gt;&lt;/span&gt;
33&lt;span id="cb1-2"&gt;&lt;a href="#cb1-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="fu"&gt;git&lt;/span&gt; worktree add &lt;span class="at"&gt;-b&lt;/span&gt; fix-stuff /path/to/tree master&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
34&lt;ol start="2" type="1"&gt;
35&lt;li&gt;&lt;code&gt;cd&lt;/code&gt; into &lt;code&gt;/path/to/tree&lt;/code&gt;&lt;/li&gt;
36&lt;li&gt;Fix, test, commit, push, party&lt;/li&gt;
37&lt;li&gt;Go back to your work, &lt;code&gt;cd -&lt;/code&gt;&lt;/li&gt;
38&lt;/ol&gt;
39&lt;p&gt;Easy as cake. You didn’t have to settle for a partially working commit, you didn’t to deal with this “stash” thing, &lt;em&gt;and&lt;/em&gt; you didn’t have to unfriend your friend. Treating each branch as a directory just &lt;em&gt;feels&lt;/em&gt; more intuitive, more UNIX-y.&lt;/p&gt;
40&lt;p&gt;A few weeks later, you find yourself singing in praise of worktrees, working on several things simultaneously. And at the same time, cursing them for being a little … clunky.&lt;/p&gt;
41&lt;h3 id="what-makes-them-clunky"&gt;What makes them clunky?&lt;/h3&gt;
42&lt;p&gt;Worktrees are great at what they claim to do. They stay out of the way when you need a checkout posthaste. However, as you start using them regularly, you realize they are not as flexible as &lt;code&gt;git checkout&lt;/code&gt; or &lt;code&gt;git switch&lt;/code&gt;.&lt;/p&gt;
43&lt;h4 id="branch-hopping"&gt;Branch-hopping&lt;/h4&gt;
44&lt;p&gt;You can &lt;code&gt;git checkout &amp;lt;branch&amp;gt;&lt;/code&gt; from anywhere within a git repository. You can’t “jump” to a worktree in the same fashion. The closest you can get, is to run &lt;code&gt;git worktree list&lt;/code&gt;, copy the path corresponding to your branch, and &lt;code&gt;cd&lt;/code&gt; into it.&lt;/p&gt;
45&lt;p&gt;Branch-hopping with the good ol’ git-checkout:&lt;/p&gt;
46&lt;div class="sourceCode" id="cb2"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb2-1"&gt;&lt;a href="#cb2-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# anywhere, anytime&lt;/span&gt;&lt;/span&gt;
47&lt;span id="cb2-2"&gt;&lt;a href="#cb2-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; git checkout feature/is-ascii-octdigit&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
48&lt;p&gt;Meanwhile, in worktree world:&lt;/p&gt;
49&lt;div class="sourceCode" id="cb3"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb3-1"&gt;&lt;a href="#cb3-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# keeping these paths in your head is hard&lt;/span&gt;&lt;/span&gt;
50&lt;span id="cb3-2"&gt;&lt;a href="#cb3-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; git worktree list&lt;/span&gt;
51&lt;span id="cb3-3"&gt;&lt;a href="#cb3-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;~/worktrees/rustc/master&lt;/span&gt; eac6c33bc63 [master]&lt;/span&gt;
52&lt;span id="cb3-4"&gt;&lt;a href="#cb3-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;~/worktrees/rustc/improve-std-char-docs&lt;/span&gt; 94cba88553e [improve-std-char-docs]&lt;/span&gt;
53&lt;span id="cb3-5"&gt;&lt;a href="#cb3-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;~/worktrees/rustc/is-ascii-octdigit&lt;/span&gt; bc57be3af7a [feature/is-ascii-octdigit]&lt;/span&gt;
54&lt;span id="cb3-6"&gt;&lt;a href="#cb3-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;~/my/other/path/oh/god&lt;/span&gt; op57or3ns7n [fix/some-error]&lt;/span&gt;
55&lt;span id="cb3-7"&gt;&lt;a href="#cb3-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
56&lt;span id="cb3-8"&gt;&lt;a href="#cb3-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; cd ~/worktrees/rustc/is-ascii-octdigit&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
57&lt;h4 id="branch-previewing"&gt;Branch-previewing&lt;/h4&gt;
58&lt;p&gt;You can “preview” branches with &lt;code&gt;git branch -v&lt;/code&gt;. However, to get an idea of what “recent activity” on a worktree looks like, you might need some juggling. You can’t glean much info about a worktree in a jiffy.&lt;/p&gt;
59&lt;p&gt;Branch-previewing with the good ol’ git-branch:&lt;/p&gt;
60&lt;div class="sourceCode" id="cb4"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb4-1"&gt;&lt;a href="#cb4-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; git branch &lt;span class="at"&gt;-v&lt;/span&gt;&lt;/span&gt;
61&lt;span id="cb4-2"&gt;&lt;a href="#cb4-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;+&lt;/span&gt; feature/is-ascii-octdigit bc57be3af7a introduce {char, u8}::is_ ...&lt;/span&gt;
62&lt;span id="cb4-3"&gt;&lt;a href="#cb4-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;+&lt;/span&gt; improve-std-char-docs 94cba88553e add whitespace in assert ...&lt;/span&gt;
63&lt;span id="cb4-4"&gt;&lt;a href="#cb4-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;*&lt;/span&gt; master eac6c33bc63 Auto merge of &lt;span class="co"&gt;#100869 - n ...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
64&lt;p&gt;Meanwhile in worktree wonderland:&lt;/p&gt;
65&lt;pre&gt;&lt;code&gt;λ git worktree list
66~/worktrees/rustc/master eac6c33bc63 [master]
67~/worktrees/rustc/improve-std-char-docs 94cba88553e [improve-std-char-docs]
68~/worktrees/rustc/is-ascii-octdigit bc57be3af7a [feature/is-ascii-octdigit]
69
70# aha, so ../is-ascii-octdigit corresponds to `feature/is-ascii-octdigit`
71λ git log feature/is-ascii-octdigit
72bc57be3af7a introduce {char, u8}::is_ascii_octdigit
73eac6c33bc63 Auto merge of #100869 - nnethercote:repl ...
74b32223fec10 Auto merge of #100707 - dzvon:fix-typo, ...
75aa857eb953e Auto merge of #100537 - petrochenkov:pic ...
76
77# extra work to make the branch &amp;lt;-&amp;gt; worktree correspondence&lt;/code&gt;&lt;/pre&gt;
78&lt;h4 id="shell-completions"&gt;Shell completions&lt;/h4&gt;
79&lt;p&gt;Lastly, you can bank on shell completions to fill in your branch whilst using &lt;code&gt;git checkout&lt;/code&gt;. Worktrees have no such conveniences.&lt;/p&gt;
80&lt;p&gt;We can mend these minor faults with fzf.&lt;/p&gt;
81&lt;h3 id="unclunkifying-worktrees"&gt;Unclunkifying worktrees&lt;/h3&gt;
82&lt;p&gt;I’d suggest looking up &lt;a href="https://github.com/junegunn/fzf"&gt;fzf&lt;/a&gt; (or &lt;a href="https://github.com/lotabout/skim"&gt;skim&lt;/a&gt; or &lt;a href="https://github.com/jhawthorn/fzy"&gt;fzy&lt;/a&gt;). These things make it cake-easy to add interactivity to your shell. Onto fixing the first minor fault, the inability to “jump” to a worktree from anywhere within a git repository.&lt;/p&gt;
83&lt;p&gt;I have a little function called &lt;code&gt;gwj&lt;/code&gt; which stands for “git worktree jump”. The idea is to list all the worktrees, select one with fzf, and &lt;code&gt;cd&lt;/code&gt; to it upon selection:&lt;/p&gt;
84&lt;div class="sourceCode" id="cb6"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb6-1"&gt;&lt;a href="#cb6-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="fu"&gt;gwj ()&lt;/span&gt; &lt;span class="kw"&gt;{&lt;/span&gt;&lt;/span&gt;
85&lt;span id="cb6-2"&gt;&lt;a href="#cb6-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="bu"&gt;local&lt;/span&gt; &lt;span class="va"&gt;out&lt;/span&gt;&lt;/span&gt;
86&lt;span id="cb6-3"&gt;&lt;a href="#cb6-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="va"&gt;out&lt;/span&gt;&lt;span class="op"&gt;=&lt;/span&gt;&lt;span class="va"&gt;$(&lt;/span&gt;&lt;span class="fu"&gt;git&lt;/span&gt; worktree list &lt;span class="kw"&gt;|&lt;/span&gt; &lt;span class="ex"&gt;fzf&lt;/span&gt; &lt;span class="kw"&gt;|&lt;/span&gt; &lt;span class="fu"&gt;awk&lt;/span&gt; &lt;span class="st"&gt;&amp;#39;{print $1}&amp;#39;&lt;/span&gt;&lt;span class="va"&gt;)&lt;/span&gt;&lt;/span&gt;
87&lt;span id="cb6-4"&gt;&lt;a href="#cb6-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="bu"&gt;cd&lt;/span&gt; &lt;span class="va"&gt;$out&lt;/span&gt;&lt;/span&gt;
88&lt;span id="cb6-5"&gt;&lt;a href="#cb6-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="kw"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
89&lt;p&gt;That is all of it really. Head into a git repository:&lt;/p&gt;
90&lt;div class="sourceCode" id="cb7"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb7-1"&gt;&lt;a href="#cb7-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# here, &amp;quot;master&amp;quot; is a directory, which contains my main&lt;/span&gt;&lt;/span&gt;
91&lt;span id="cb7-2"&gt;&lt;a href="#cb7-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# worktree: a checkout of the master branch on rust-lang/rust &lt;/span&gt;&lt;/span&gt;
92&lt;span id="cb7-3"&gt;&lt;a href="#cb7-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; cd ~/worktrees/rustc/master/library/core/src&lt;/span&gt;
93&lt;span id="cb7-4"&gt;&lt;a href="#cb7-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; &lt;span class="co"&gt;# hack away&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
94&lt;p&gt;Preferably one with a few worktrees:&lt;/p&gt;
95&lt;div class="sourceCode" id="cb8"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb8-1"&gt;&lt;a href="#cb8-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; git worktree list&lt;/span&gt;
96&lt;span id="cb8-2"&gt;&lt;a href="#cb8-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;~/worktrees/rustc/master&lt;/span&gt; eac6c33bc63 [master]&lt;/span&gt;
97&lt;span id="cb8-3"&gt;&lt;a href="#cb8-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;~/worktrees/rustc/improve-std-char-docs&lt;/span&gt; 94cba88553e [improve-std-char-docs]&lt;/span&gt;
98&lt;span id="cb8-4"&gt;&lt;a href="#cb8-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;~/worktrees/rustc/is-ascii-octdigit&lt;/span&gt; bc57be3af7a [feature/is-ascii-octdigit]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
99&lt;p&gt;And hit &lt;code&gt;gwj&lt;/code&gt; (pretend that the pipe, |, is your cursor):&lt;/p&gt;
100&lt;div class="sourceCode" id="cb9"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb9-1"&gt;&lt;a href="#cb9-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; gwj&lt;/span&gt;
101&lt;span id="cb9-2"&gt;&lt;a href="#cb9-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="op"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kw"&gt;|&lt;/span&gt;&lt;/span&gt;
102&lt;span id="cb9-3"&gt;&lt;a href="#cb9-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;4/4&lt;/span&gt;&lt;/span&gt;
103&lt;span id="cb9-4"&gt;&lt;a href="#cb9-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="op"&gt;&amp;gt;&lt;/span&gt; ~/worktrees/rustc/master &lt;span class="ex"&gt;eac6c33bc63&lt;/span&gt; [master]&lt;/span&gt;
104&lt;span id="cb9-5"&gt;&lt;a href="#cb9-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;~/worktrees/rustc/improve-std-char-docs&lt;/span&gt; 94cba88553e [improve-std-char-docs]&lt;/span&gt;
105&lt;span id="cb9-6"&gt;&lt;a href="#cb9-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;~/worktrees/rustc/is-ascii-octdigit&lt;/span&gt; bc57be3af7a [feature/is-ascii-octdigit]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
106&lt;p&gt;Approximately type in your branch of choice:&lt;/p&gt;
107&lt;div class="sourceCode" id="cb10"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb10-1"&gt;&lt;a href="#cb10-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; gwj&lt;/span&gt;
108&lt;span id="cb10-2"&gt;&lt;a href="#cb10-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="op"&gt;&amp;gt;&lt;/span&gt; docs&lt;span class="kw"&gt;|&lt;/span&gt;&lt;/span&gt;
109&lt;span id="cb10-3"&gt;&lt;a href="#cb10-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;4/4&lt;/span&gt;&lt;/span&gt;
110&lt;span id="cb10-4"&gt;&lt;a href="#cb10-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="op"&gt;&amp;gt;&lt;/span&gt; ~/worktrees/rustc/improve-std-char-docs &lt;span class="ex"&gt;94cba88553e&lt;/span&gt; [improve-std-char-docs]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
111&lt;p&gt;And hit enter. You should find yourself in the selected worktree.&lt;/p&gt;
112&lt;p&gt;Onward, to the next fault, lack of preview-bility. We can utilize fzf’s aptly named &lt;code&gt;--preview&lt;/code&gt; flag, to, well, preview our worktree before performing a selection:&lt;/p&gt;
113&lt;div class="sourceCode" id="cb11"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb11-1"&gt;&lt;a href="#cb11-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="fu"&gt;gwj ()&lt;/span&gt; &lt;span class="kw"&gt;{&lt;/span&gt;&lt;/span&gt;
114&lt;span id="cb11-2"&gt;&lt;a href="#cb11-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="bu"&gt;local&lt;/span&gt; &lt;span class="va"&gt;out&lt;/span&gt;&lt;/span&gt;
115&lt;span id="cb11-3"&gt;&lt;a href="#cb11-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="va"&gt;out&lt;/span&gt;&lt;span class="op"&gt;=&lt;/span&gt;&lt;span class="va"&gt;$(&lt;/span&gt;&lt;/span&gt;
116&lt;span id="cb11-4"&gt;&lt;a href="#cb11-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="fu"&gt;git&lt;/span&gt; worktree list &lt;span class="kw"&gt;|&lt;/span&gt;&lt;/span&gt;
117&lt;span id="cb11-5"&gt;&lt;a href="#cb11-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;fzf&lt;/span&gt; &lt;span class="at"&gt;--preview&lt;/span&gt;&lt;span class="op"&gt;=&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;git log --oneline -n10 {2}&amp;#39;&lt;/span&gt; &lt;span class="kw"&gt;|&lt;/span&gt;&lt;/span&gt;
118&lt;span id="cb11-6"&gt;&lt;a href="#cb11-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="fu"&gt;awk&lt;/span&gt; &lt;span class="st"&gt;&amp;#39;{print $1}&amp;#39;&lt;/span&gt;&lt;/span&gt;
119&lt;span id="cb11-7"&gt;&lt;a href="#cb11-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="va"&gt;)&lt;/span&gt;&lt;/span&gt;
120&lt;span id="cb11-8"&gt;&lt;a href="#cb11-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="bu"&gt;cd&lt;/span&gt; &lt;span class="va"&gt;$out&lt;/span&gt;&lt;/span&gt;
121&lt;span id="cb11-9"&gt;&lt;a href="#cb11-9" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="kw"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
122&lt;p&gt;Once again, hit &lt;code&gt;gwj&lt;/code&gt; inside a git repository with linked worktrees:&lt;/p&gt;
123&lt;div class="sourceCode" id="cb12"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb12-1"&gt;&lt;a href="#cb12-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; gwj&lt;/span&gt;
124&lt;span id="cb12-2"&gt;&lt;a href="#cb12-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;╭─────────────────────────────────────────────────────────╮&lt;/span&gt;&lt;/span&gt;
125&lt;span id="cb12-3"&gt;&lt;a href="#cb12-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│&lt;/span&gt; eac6c33bc63 Auto merge of 100869 nnethercote:replace... │&lt;/span&gt;
126&lt;span id="cb12-4"&gt;&lt;a href="#cb12-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│&lt;/span&gt; b32223fec10 Auto merge of 100707 dzvon:fix-typo, r=d... │&lt;/span&gt;
127&lt;span id="cb12-5"&gt;&lt;a href="#cb12-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│&lt;/span&gt; aa857eb953e Auto merge of 100537 petrochenkov:picche... │&lt;/span&gt;
128&lt;span id="cb12-6"&gt;&lt;a href="#cb12-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│&lt;/span&gt; 3892b7074da Auto merge of 100210 mystor:proc_macro_d... │&lt;/span&gt;
129&lt;span id="cb12-7"&gt;&lt;a href="#cb12-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│&lt;/span&gt; db00199d999 Auto merge of 101249 matthiaskrgr:rollup... │&lt;/span&gt;
130&lt;span id="cb12-8"&gt;&lt;a href="#cb12-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│&lt;/span&gt; 14d216d33ba Rollup merge of 101240 JohnTitor:JohnTit... │&lt;/span&gt;
131&lt;span id="cb12-9"&gt;&lt;a href="#cb12-9" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│&lt;/span&gt; 3da66f03531 Rollup merge of 101236 thomcc:winfs-noze... │&lt;/span&gt;
132&lt;span id="cb12-10"&gt;&lt;a href="#cb12-10" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│&lt;/span&gt; 0620f6e90af Rollup merge of 101230 davidtwco:transla... │&lt;/span&gt;
133&lt;span id="cb12-11"&gt;&lt;a href="#cb12-11" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│&lt;/span&gt; c30c42ee299 Rollup merge of 101229 mgeisler:link-try... │&lt;/span&gt;
134&lt;span id="cb12-12"&gt;&lt;a href="#cb12-12" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│&lt;/span&gt; e5356712b9e Rollup merge of 101165 ldm0:drain_to_ite... │&lt;/span&gt;
135&lt;span id="cb12-13"&gt;&lt;a href="#cb12-13" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;╰─────────────────────────────────────────────────────────╯&lt;/span&gt;&lt;/span&gt;
136&lt;span id="cb12-14"&gt;&lt;a href="#cb12-14" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="op"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
137&lt;span id="cb12-15"&gt;&lt;a href="#cb12-15" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;4/4&lt;/span&gt;&lt;/span&gt;
138&lt;span id="cb12-16"&gt;&lt;a href="#cb12-16" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="op"&gt;&amp;gt;&lt;/span&gt; /home/np/worktrees/compiler/master &lt;span class="ex"&gt;eac6c...&lt;/span&gt;&lt;/span&gt;
139&lt;span id="cb12-17"&gt;&lt;a href="#cb12-17" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;/home/np/worktrees/compiler/improve-std-char-docs&lt;/span&gt; 94cba...&lt;/span&gt;
140&lt;span id="cb12-18"&gt;&lt;a href="#cb12-18" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;/home/np/worktrees/compiler/is-ascii-octdigit&lt;/span&gt; bc57b...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
141&lt;p&gt;A fancy preview of the last 10 commits on the branch that the selected worktree corresponds to. In other words, sight for sore eyes. Our little script is already shaping up to be useful, you hit &lt;code&gt;gwj&lt;/code&gt;, browse through your worktrees, preview each one and automatically &lt;code&gt;cd&lt;/code&gt; to your selection. But we are not done yet.&lt;/p&gt;
142&lt;p&gt;The last fault was lack shell completions. A quick review of what a shell completion really does:&lt;/p&gt;
143&lt;div class="sourceCode" id="cb13"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb13-1"&gt;&lt;a href="#cb13-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; git checkout f&lt;span class="op"&gt;&amp;lt;&lt;/span&gt;tab&lt;span class="op"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
144&lt;span id="cb13-2"&gt;&lt;a href="#cb13-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;feature/is-ascii-octdigit&lt;/span&gt;&lt;/span&gt;
145&lt;span id="cb13-3"&gt;&lt;a href="#cb13-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;fix/some-error&lt;/span&gt;&lt;/span&gt;
146&lt;span id="cb13-4"&gt;&lt;a href="#cb13-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;format-doc-tests&lt;/span&gt;&lt;/span&gt;
147&lt;span id="cb13-5"&gt;&lt;a href="#cb13-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
148&lt;span id="cb13-6"&gt;&lt;a href="#cb13-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; git checkout feat&lt;span class="op"&gt;&amp;lt;&lt;/span&gt;tab&lt;span class="op"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
149&lt;span id="cb13-7"&gt;&lt;a href="#cb13-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
150&lt;span id="cb13-8"&gt;&lt;a href="#cb13-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; git checkout feature/is-ascii-octdigit&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
151&lt;p&gt;Each time you hit “tab”, the shell produces a few “completion candidates”, and once you have just a single candidate left, the shell inserts that for you directly into your edit line. Of course, this process varies from shell to shell.&lt;/p&gt;
152&lt;p&gt;fzf narrows down your options as you type into the prompt, but you still have to:&lt;/p&gt;
153&lt;ol type="1"&gt;
154&lt;li&gt;Type &lt;code&gt;gwj&lt;/code&gt;&lt;/li&gt;
155&lt;li&gt;Hit enter&lt;/li&gt;
156&lt;li&gt;Type out a query and narrow down your search&lt;/li&gt;
157&lt;li&gt;Hit enter&lt;/li&gt;
158&lt;/ol&gt;
159&lt;p&gt;We can speed that up a bit, have fzf narrow down the candidates on startup, just like our shell does:&lt;/p&gt;
160&lt;div class="sourceCode" id="cb14"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb14-1"&gt;&lt;a href="#cb14-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="fu"&gt;gwj ()&lt;/span&gt; &lt;span class="kw"&gt;{&lt;/span&gt;&lt;/span&gt;
161&lt;span id="cb14-2"&gt;&lt;a href="#cb14-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="bu"&gt;local&lt;/span&gt; &lt;span class="va"&gt;out&lt;/span&gt; &lt;span class="va"&gt;query&lt;/span&gt;&lt;/span&gt;
162&lt;span id="cb14-3"&gt;&lt;a href="#cb14-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="va"&gt;query&lt;/span&gt;&lt;span class="op"&gt;=&lt;/span&gt;&lt;span class="st"&gt;&amp;quot;&lt;/span&gt;&lt;span class="va"&gt;${1&lt;/span&gt;&lt;span class="op"&gt;:-&lt;/span&gt; &lt;span class="va"&gt;}&lt;/span&gt;&lt;span class="st"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
163&lt;span id="cb14-4"&gt;&lt;a href="#cb14-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="va"&gt;out&lt;/span&gt;&lt;span class="op"&gt;=&lt;/span&gt;&lt;span class="va"&gt;$(&lt;/span&gt;&lt;/span&gt;
164&lt;span id="cb14-5"&gt;&lt;a href="#cb14-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="fu"&gt;git&lt;/span&gt; worktree list &lt;span class="kw"&gt;|&lt;/span&gt;&lt;/span&gt;
165&lt;span id="cb14-6"&gt;&lt;a href="#cb14-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;fzf&lt;/span&gt; &lt;span class="at"&gt;--preview&lt;/span&gt;&lt;span class="op"&gt;=&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;git log --oneline -n10 {2}&amp;#39;&lt;/span&gt; &lt;span class="at"&gt;--query&lt;/span&gt; &lt;span class="st"&gt;&amp;quot;&lt;/span&gt;&lt;span class="va"&gt;$query&lt;/span&gt;&lt;span class="st"&gt;&amp;quot;&lt;/span&gt; &lt;span class="at"&gt;-1&lt;/span&gt; &lt;span class="kw"&gt;|&lt;/span&gt;&lt;/span&gt;
166&lt;span id="cb14-7"&gt;&lt;a href="#cb14-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="fu"&gt;awk&lt;/span&gt; &lt;span class="st"&gt;&amp;#39;{print $1}&amp;#39;&lt;/span&gt;&lt;/span&gt;
167&lt;span id="cb14-8"&gt;&lt;a href="#cb14-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="va"&gt;)&lt;/span&gt;&lt;/span&gt;
168&lt;span id="cb14-9"&gt;&lt;a href="#cb14-9" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="bu"&gt;cd&lt;/span&gt; &lt;span class="va"&gt;$out&lt;/span&gt;&lt;/span&gt;
169&lt;span id="cb14-10"&gt;&lt;a href="#cb14-10" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="kw"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
170&lt;p&gt;The change is extremely tiny, blink-and-you’ll-miss-it kinda tiny. We added a little &lt;code&gt;--query&lt;/code&gt; flag, that allows you to prefill the prompt, and the &lt;code&gt;-1&lt;/code&gt; flag, that avoids the interactive finder if only one match exists on startup:&lt;/p&gt;
171&lt;div class="sourceCode" id="cb15"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb15-1"&gt;&lt;a href="#cb15-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# skip through the fzf prompt:&lt;/span&gt;&lt;/span&gt;
172&lt;span id="cb15-2"&gt;&lt;a href="#cb15-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; gwj master&lt;/span&gt;
173&lt;span id="cb15-3"&gt;&lt;a href="#cb15-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# cd -- ~/worktrees/rustc/master&lt;/span&gt;&lt;/span&gt;
174&lt;span id="cb15-4"&gt;&lt;a href="#cb15-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
175&lt;span id="cb15-5"&gt;&lt;a href="#cb15-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# more than one option, we end up in the interactive finder&lt;/span&gt;&lt;/span&gt;
176&lt;span id="cb15-6"&gt;&lt;a href="#cb15-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;λ&lt;/span&gt; gwj improve&lt;/span&gt;
177&lt;span id="cb15-7"&gt;&lt;a href="#cb15-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;╭─────────────────────────────────────────────────────────╮&lt;/span&gt;&lt;/span&gt;
178&lt;span id="cb15-8"&gt;&lt;a href="#cb15-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│&lt;/span&gt; eac6c33bc63 Auto merge of 100869 nnethercote:replace... │&lt;/span&gt;
179&lt;span id="cb15-9"&gt;&lt;a href="#cb15-9" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│&lt;/span&gt; b32223fec10 Auto merge of 100707 dzvon:fix-typo, r=d... │&lt;/span&gt;
180&lt;span id="cb15-10"&gt;&lt;a href="#cb15-10" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│&lt;/span&gt; aa857eb953e Auto merge of 100537 petrochenkov:picche... │&lt;/span&gt;
181&lt;span id="cb15-11"&gt;&lt;a href="#cb15-11" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;╰─────────────────────────────────────────────────────────╯&lt;/span&gt;&lt;/span&gt;
182&lt;span id="cb15-12"&gt;&lt;a href="#cb15-12" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="op"&gt;&amp;gt;&lt;/span&gt; improve&lt;/span&gt;
183&lt;span id="cb15-13"&gt;&lt;a href="#cb15-13" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;2/2&lt;/span&gt;&lt;/span&gt;
184&lt;span id="cb15-14"&gt;&lt;a href="#cb15-14" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="op"&gt;&amp;gt;&lt;/span&gt; /home/np/worktrees/compiler/improve-const-perf &lt;span class="ex"&gt;eac6c...&lt;/span&gt;&lt;/span&gt;
185&lt;span id="cb15-15"&gt;&lt;a href="#cb15-15" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;/home/np/worktrees/compiler/improve-std-char-docs&lt;/span&gt; 94cba...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
186&lt;p&gt;Throw some error handling in there, hook up a similar script to improve the UX of &lt;code&gt;git worktree remove&lt;/code&gt;, go wild. A few more helpers I’ve got:&lt;/p&gt;
187&lt;div class="sourceCode" id="cb16"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb16-1"&gt;&lt;a href="#cb16-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# gwa /path/to/branch-name&lt;/span&gt;&lt;/span&gt;
188&lt;span id="cb16-2"&gt;&lt;a href="#cb16-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# creates a new branch and &amp;quot;switches&amp;quot; to it&lt;/span&gt;&lt;/span&gt;
189&lt;span id="cb16-3"&gt;&lt;a href="#cb16-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="kw"&gt;function&lt;/span&gt;&lt;span class="fu"&gt; gwa ()&lt;/span&gt; &lt;span class="kw"&gt;{&lt;/span&gt;&lt;/span&gt;
190&lt;span id="cb16-4"&gt;&lt;a href="#cb16-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="fu"&gt;git&lt;/span&gt; worktree add &lt;span class="st"&gt;&amp;quot;&lt;/span&gt;&lt;span class="va"&gt;$1&lt;/span&gt;&lt;span class="st"&gt;&amp;quot;&lt;/span&gt; &lt;span class="kw"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="bu"&gt;cd&lt;/span&gt; &lt;span class="st"&gt;&amp;quot;&lt;/span&gt;&lt;span class="va"&gt;$1&lt;/span&gt;&lt;span class="st"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
191&lt;span id="cb16-5"&gt;&lt;a href="#cb16-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="kw"&gt;}&lt;/span&gt;&lt;/span&gt;
192&lt;span id="cb16-6"&gt;&lt;a href="#cb16-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
193&lt;span id="cb16-7"&gt;&lt;a href="#cb16-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="bu"&gt;alias&lt;/span&gt; gwls=&lt;span class="st"&gt;&amp;quot;git worktree list&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
194<link>https://peppe.rs/posts/curing_a_case_of_git-UX/</link>
195<pubDate>Sat, 03 Sep 2022 03:18:00 +0000</pubDate>
196<guid>https://peppe.rs/posts/curing_a_case_of_git-UX/</guid>
197</item>
198<item>
15<title>Programming On 34 Keys</title> 199<title>Programming On 34 Keys</title>
16<description>&lt;p&gt;Minimizing your keyboard layout is a slippery slope. A few months ago, I built the &lt;a href="https://github.com/icyphox/ferricy"&gt;Ferricy&lt;/a&gt;, a 34-key-split-ortho-ergo keyboard. The Ferricy is a fork of the &lt;a href="https://github.com/davidphilipbarr/Sweep/tree/main/Sweep%20Bling%20MX"&gt;Ferris Sweep MX Bling&lt;/a&gt;.&lt;/p&gt; 200<description>&lt;p&gt;Minimizing your keyboard layout is a slippery slope. A few months ago, I built the &lt;a href="https://github.com/icyphox/ferricy"&gt;Ferricy&lt;/a&gt;, a 34-key-split-ortho-ergo keyboard. The Ferricy is a fork of the &lt;a href="https://github.com/davidphilipbarr/Sweep/tree/main/Sweep%20Bling%20MX"&gt;Ferris Sweep MX Bling&lt;/a&gt;.&lt;/p&gt;
17&lt;figure&gt; 201&lt;figure&gt;