diff options
author | Akshay <[email protected]> | 2023-02-12 06:43:49 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2023-02-12 06:43:49 +0000 |
commit | 366df8852f503523cc4f9046d82ba9a99dd51d7f (patch) | |
tree | 635884dd5700cdc2a22a8885031aa67816bbe1b0 /docs/posts/curing_a_case_of_git-UX/index.html | |
parent | 57a1fc656e05e1fcf07e4cff3dc988c6b5c2bc59 (diff) |
new art: lapse
Diffstat (limited to 'docs/posts/curing_a_case_of_git-UX/index.html')
-rw-r--r-- | docs/posts/curing_a_case_of_git-UX/index.html | 180 |
1 files changed, 128 insertions, 52 deletions
diff --git a/docs/posts/curing_a_case_of_git-UX/index.html b/docs/posts/curing_a_case_of_git-UX/index.html index 9c4761c..140436a 100644 --- a/docs/posts/curing_a_case_of_git-UX/index.html +++ b/docs/posts/curing_a_case_of_git-UX/index.html | |||
@@ -33,7 +33,7 @@ | |||
33 | <span class="stats-unit">cm</span> | 33 | <span class="stats-unit">cm</span> |
34 |   | 34 |   |
35 | <span class="stats-number"> | 35 | <span class="stats-number"> |
36 | 9.5 | 36 | 9.6 |
37 | </span> | 37 | </span> |
38 | <span class="stats-unit">min</span> | 38 | <span class="stats-unit">min</span> |
39 | </div> | 39 | </div> |
@@ -42,51 +42,86 @@ | |||
42 | Curing A Case Of Git-UX | 42 | Curing A Case Of Git-UX |
43 | </h1> | 43 | </h1> |
44 | <div class="post-text"> | 44 | <div class="post-text"> |
45 | <p>Git worktrees are great, but they fall behind the venerable <code>git checkout</code> sometimes. I attempted to fix that with <a href="https://github.com/junegunn/fzf">fzf</a> and a bit of bash.</p> | 45 | <p>Git worktrees are great, but they fall behind the venerable |
46 | <p><a href="https://asciinema.org/a/D297ztKRzpE4gAHbPTPmkqYps"><img src="https://asciinema.org/a/D297ztKRzpE4gAHbPTPmkqYps.svg" /></a></p> | 46 | <code>git checkout</code> sometimes. I attempted to fix that with <a |
47 | <p>Fear not if you haven’t heard of “worktrees”, I have included a primer here.<br /> | 47 | href="https://github.com/junegunn/fzf">fzf</a> and a bit of bash.</p> |
48 | <p><a href="https://asciinema.org/a/D297ztKRzpE4gAHbPTPmkqYps"><img | ||
49 | src="https://asciinema.org/a/D297ztKRzpE4gAHbPTPmkqYps.svg" /></a></p> | ||
50 | <p>Fear not if you haven’t heard of “worktrees”, I have included a | ||
51 | primer here.<br /> | ||
48 | <a href="#what-makes-them-clunky">Skip the primer -></a>.</p> | 52 | <a href="#what-makes-them-clunky">Skip the primer -></a>.</p> |
49 | <h3 id="why-worktrees">Why Worktrees?</h3> | 53 | <h3 id="why-worktrees">Why Worktrees?</h3> |
50 | <p>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:</p> | 54 | <p>Picture this. You are whacking away on a feature branch. Halfway |
55 | there, in fact. Your friend asks you fix something urgently. You proceed | ||
56 | to do one of three things:</p> | ||
51 | <ul> | 57 | <ul> |
52 | <li>create a temporary branch, make a WIP commit, begin working on the fix</li> | 58 | <li>create a temporary branch, make a WIP commit, begin working on the |
59 | fix</li> | ||
53 | <li>stash away your changes, begin working on the fix</li> | 60 | <li>stash away your changes, begin working on the fix</li> |
54 | <li>unfriend said friend for disturbing your flow</li> | 61 | <li>unfriend said friend for disturbing your flow</li> |
55 | </ul> | 62 | </ul> |
56 | <p>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 <em>thinking</em> so much?</p> | 63 | <p>All of these options are … subpar. With the temporary branch, you are |
57 | <p>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:</p> | 64 | forced to create a partial, non-working commit, and then reset said |
65 | commit once done with the fix. With the stash approach, you are required | ||
66 | to now keep a mental model of the stash, be aware of untracked files | ||
67 | that don’t get stashed by default, etc. Why won’t git just let you work | ||
68 | on two things at the same time without <em>thinking</em> so much?</p> | ||
69 | <p>That is exactly what worktrees let you do. Worktrees let you have | ||
70 | more than one checkout at a time, each checkout in a separate directory. | ||
71 | Like creating a new clone, but safer (it disallows checking out the same | ||
72 | branch twice) and a lot more space efficient (the new working tree is | ||
73 | “linked” to the “main” worktree, and a good amount of stuff is shared). | ||
74 | When your friend asks you to make the fix, you proceed like so:</p> | ||
58 | <ol type="1"> | 75 | <ol type="1"> |
59 | <li>Create a new working tree with:</li> | 76 | <li>Create a new working tree with:</li> |
60 | </ol> | 77 | </ol> |
61 | <div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># git worktree add -b <branch-name> <path> <from></span></span> | 78 | <div class="sourceCode" id="cb1"><pre |
79 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># git worktree add -b <branch-name> <path> <from></span></span> | ||
62 | <span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> worktree add <span class="at">-b</span> fix-stuff /path/to/tree master</span></code></pre></div> | 80 | <span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> worktree add <span class="at">-b</span> fix-stuff /path/to/tree master</span></code></pre></div> |
63 | <ol start="2" type="1"> | 81 | <ol start="2" type="1"> |
64 | <li><code>cd</code> into <code>/path/to/tree</code></li> | 82 | <li><code>cd</code> into <code>/path/to/tree</code></li> |
65 | <li>Fix, test, commit, push, party</li> | 83 | <li>Fix, test, commit, push, party</li> |
66 | <li>Go back to your work, <code>cd -</code></li> | 84 | <li>Go back to your work, <code>cd -</code></li> |
67 | </ol> | 85 | </ol> |
68 | <p>Easy as cake. You didn’t have to settle for a partially working commit, you didn’t to deal with this “stash” thing, <em>and</em> you didn’t have to unfriend your friend. Treating each branch as a directory just <em>feels</em> more intuitive, more UNIX-y.</p> | 86 | <p>Easy as cake. You didn’t have to settle for a partially working |
69 | <p>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.</p> | 87 | commit, you didn’t to deal with this “stash” thing, <em>and</em> you |
88 | didn’t have to unfriend your friend. Treating each branch as a directory | ||
89 | just <em>feels</em> more intuitive, more UNIX-y.</p> | ||
90 | <p>A few weeks later, you find yourself singing in praise of worktrees, | ||
91 | working on several things simultaneously. And at the same time, cursing | ||
92 | them for being a little … clunky.</p> | ||
70 | <h3 id="what-makes-them-clunky">What makes them clunky?</h3> | 93 | <h3 id="what-makes-them-clunky">What makes them clunky?</h3> |
71 | <p>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 <code>git checkout</code> or <code>git switch</code>.</p> | 94 | <p>Worktrees are great at what they claim to do. They stay out of the |
95 | way when you need a checkout posthaste. However, as you start using them | ||
96 | regularly, you realize they are not as flexible as | ||
97 | <code>git checkout</code> or <code>git switch</code>.</p> | ||
72 | <h4 id="branch-hopping">Branch-hopping</h4> | 98 | <h4 id="branch-hopping">Branch-hopping</h4> |
73 | <p>You can <code>git checkout <branch></code> 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 <code>git worktree list</code>, copy the path corresponding to your branch, and <code>cd</code> into it.</p> | 99 | <p>You can <code>git checkout <branch></code> from anywhere within |
100 | a git repository. You can’t “jump” to a worktree in the same fashion. | ||
101 | The closest you can get, is to run <code>git worktree list</code>, copy | ||
102 | the path corresponding to your branch, and <code>cd</code> into it.</p> | ||
74 | <p>Branch-hopping with the good ol’ git-checkout:</p> | 103 | <p>Branch-hopping with the good ol’ git-checkout:</p> |
75 | <div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># anywhere, anytime</span></span> | 104 | <div class="sourceCode" id="cb2"><pre |
105 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># anywhere, anytime</span></span> | ||
76 | <span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git checkout feature/is-ascii-octdigit</span></code></pre></div> | 106 | <span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git checkout feature/is-ascii-octdigit</span></code></pre></div> |
77 | <p>Meanwhile, in worktree world:</p> | 107 | <p>Meanwhile, in worktree world:</p> |
78 | <div class="sourceCode" id="cb3"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># keeping these paths in your head is hard</span></span> | 108 | <div class="sourceCode" id="cb3"><pre |
109 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># keeping these paths in your head is hard</span></span> | ||
79 | <span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git worktree list</span> | 110 | <span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git worktree list</span> |
80 | <span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">~/worktrees/rustc/master</span> eac6c33bc63 [master]</span> | 111 | <span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">~/worktrees/rustc/master</span> eac6c33bc63 <span class="pp">[</span><span class="ss">master</span><span class="pp">]</span></span> |
81 | <span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="ex">~/worktrees/rustc/improve-std-char-docs</span> 94cba88553e [improve-std-char-docs]</span> | 112 | <span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="ex">~/worktrees/rustc/improve-std-char-docs</span> 94cba88553e <span class="pp">[</span><span class="ss">improve</span><span class="pp">-</span><span class="ss">std</span><span class="pp">-</span><span class="ss">char</span><span class="pp">-</span><span class="ss">docs</span><span class="pp">]</span></span> |
82 | <span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="ex">~/worktrees/rustc/is-ascii-octdigit</span> bc57be3af7a [feature/is-ascii-octdigit]</span> | 113 | <span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="ex">~/worktrees/rustc/is-ascii-octdigit</span> bc57be3af7a <span class="pp">[</span><span class="ss">feature/is</span><span class="pp">-</span><span class="ss">ascii</span><span class="pp">-</span><span class="ss">octdigit</span><span class="pp">]</span></span> |
83 | <span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="ex">~/my/other/path/oh/god</span> op57or3ns7n [fix/some-error]</span> | 114 | <span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="ex">~/my/other/path/oh/god</span> op57or3ns7n <span class="pp">[</span><span class="ss">fix/some</span><span class="pp">-</span><span class="ss">error</span><span class="pp">]</span></span> |
84 | <span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a></span> | 115 | <span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a></span> |
85 | <span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> cd ~/worktrees/rustc/is-ascii-octdigit</span></code></pre></div> | 116 | <span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> cd ~/worktrees/rustc/is-ascii-octdigit</span></code></pre></div> |
86 | <h4 id="branch-previewing">Branch-previewing</h4> | 117 | <h4 id="branch-previewing">Branch-previewing</h4> |
87 | <p>You can “preview” branches with <code>git branch -v</code>. 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.</p> | 118 | <p>You can “preview” branches with <code>git branch -v</code>. However, |
119 | to get an idea of what “recent activity” on a worktree looks like, you | ||
120 | might need some juggling. You can’t glean much info about a worktree in | ||
121 | a jiffy.</p> | ||
88 | <p>Branch-previewing with the good ol’ git-branch:</p> | 122 | <p>Branch-previewing with the good ol’ git-branch:</p> |
89 | <div class="sourceCode" id="cb4"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git branch <span class="at">-v</span></span> | 123 | <div class="sourceCode" id="cb4"><pre |
124 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git branch <span class="at">-v</span></span> | ||
90 | <span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="ex">+</span> feature/is-ascii-octdigit bc57be3af7a introduce {char, u8}::is_ ...</span> | 125 | <span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="ex">+</span> feature/is-ascii-octdigit bc57be3af7a introduce {char, u8}::is_ ...</span> |
91 | <span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="ex">+</span> improve-std-char-docs 94cba88553e add whitespace in assert ...</span> | 126 | <span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="ex">+</span> improve-std-char-docs 94cba88553e add whitespace in assert ...</span> |
92 | <span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="ex">*</span> master eac6c33bc63 Auto merge of <span class="co">#100869 - n ...</span></span></code></pre></div> | 127 | <span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="ex">*</span> master eac6c33bc63 Auto merge of <span class="co">#100869 - n ...</span></span></code></pre></div> |
@@ -105,41 +140,60 @@ aa857eb953e Auto merge of #100537 - petrochenkov:pic ... | |||
105 | 140 | ||
106 | # extra work to make the branch <-> worktree correspondence</code></pre> | 141 | # extra work to make the branch <-> worktree correspondence</code></pre> |
107 | <h4 id="shell-completions">Shell completions</h4> | 142 | <h4 id="shell-completions">Shell completions</h4> |
108 | <p>Lastly, you can bank on shell completions to fill in your branch whilst using <code>git checkout</code>. Worktrees have no such conveniences.</p> | 143 | <p>Lastly, you can bank on shell completions to fill in your branch |
144 | whilst using <code>git checkout</code>. Worktrees have no such | ||
145 | conveniences.</p> | ||
109 | <p>We can mend these minor faults with fzf.</p> | 146 | <p>We can mend these minor faults with fzf.</p> |
110 | <h3 id="unclunkifying-worktrees">Unclunkifying worktrees</h3> | 147 | <h3 id="unclunkifying-worktrees">Unclunkifying worktrees</h3> |
111 | <p>I’d suggest looking up <a href="https://github.com/junegunn/fzf">fzf</a> (or <a href="https://github.com/lotabout/skim">skim</a> or <a href="https://github.com/jhawthorn/fzy">fzy</a>). 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.</p> | 148 | <p>I’d suggest looking up <a |
112 | <p>I have a little function called <code>gwj</code> which stands for “git worktree jump”. The idea is to list all the worktrees, select one with fzf, and <code>cd</code> to it upon selection:</p> | 149 | href="https://github.com/junegunn/fzf">fzf</a> (or <a |
113 | <div class="sourceCode" id="cb6"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">gwj ()</span> <span class="kw">{</span></span> | 150 | href="https://github.com/lotabout/skim">skim</a> or <a |
151 | href="https://github.com/jhawthorn/fzy">fzy</a>). These things make it | ||
152 | cake-easy to add interactivity to your shell. Onto fixing the first | ||
153 | minor fault, the inability to “jump” to a worktree from anywhere within | ||
154 | a git repository.</p> | ||
155 | <p>I have a little function called <code>gwj</code> which stands for | ||
156 | “git worktree jump”. The idea is to list all the worktrees, select one | ||
157 | with fzf, and <code>cd</code> to it upon selection:</p> | ||
158 | <div class="sourceCode" id="cb6"><pre | ||
159 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">gwj ()</span> <span class="kw">{</span></span> | ||
114 | <span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">local</span> <span class="va">out</span></span> | 160 | <span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">local</span> <span class="va">out</span></span> |
115 | <span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="va">out</span><span class="op">=</span><span class="va">$(</span><span class="fu">git</span> worktree list <span class="kw">|</span> <span class="ex">fzf</span> <span class="kw">|</span> <span class="fu">awk</span> <span class="st">'{print $1}'</span><span class="va">)</span></span> | 161 | <span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="va">out</span><span class="op">=</span><span class="va">$(</span><span class="fu">git</span> worktree list <span class="kw">|</span> <span class="ex">fzf</span> <span class="kw">|</span> <span class="fu">awk</span> <span class="st">'{print $1}'</span><span class="va">)</span></span> |
116 | <span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a> <span class="bu">cd</span> <span class="va">$out</span></span> | 162 | <span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a> <span class="bu">cd</span> <span class="va">$out</span></span> |
117 | <span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a><span class="kw">}</span></span></code></pre></div> | 163 | <span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a><span class="kw">}</span></span></code></pre></div> |
118 | <p>That is all of it really. Head into a git repository:</p> | 164 | <p>That is all of it really. Head into a git repository:</p> |
119 | <div class="sourceCode" id="cb7"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co"># here, "master" is a directory, which contains my main</span></span> | 165 | <div class="sourceCode" id="cb7"><pre |
166 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co"># here, "master" is a directory, which contains my main</span></span> | ||
120 | <span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="co"># worktree: a checkout of the master branch on rust-lang/rust </span></span> | 167 | <span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="co"># worktree: a checkout of the master branch on rust-lang/rust </span></span> |
121 | <span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> cd ~/worktrees/rustc/master/library/core/src</span> | 168 | <span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> cd ~/worktrees/rustc/master/library/core/src</span> |
122 | <span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> <span class="co"># hack away</span></span></code></pre></div> | 169 | <span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> <span class="co"># hack away</span></span></code></pre></div> |
123 | <p>Preferably one with a few worktrees:</p> | 170 | <p>Preferably one with a few worktrees:</p> |
124 | <div class="sourceCode" id="cb8"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git worktree list</span> | 171 | <div class="sourceCode" id="cb8"><pre |
125 | <span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="ex">~/worktrees/rustc/master</span> eac6c33bc63 [master]</span> | 172 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git worktree list</span> |
126 | <span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="ex">~/worktrees/rustc/improve-std-char-docs</span> 94cba88553e [improve-std-char-docs]</span> | 173 | <span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="ex">~/worktrees/rustc/master</span> eac6c33bc63 <span class="pp">[</span><span class="ss">master</span><span class="pp">]</span></span> |
127 | <span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a><span class="ex">~/worktrees/rustc/is-ascii-octdigit</span> bc57be3af7a [feature/is-ascii-octdigit]</span></code></pre></div> | 174 | <span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="ex">~/worktrees/rustc/improve-std-char-docs</span> 94cba88553e <span class="pp">[</span><span class="ss">improve</span><span class="pp">-</span><span class="ss">std</span><span class="pp">-</span><span class="ss">char</span><span class="pp">-</span><span class="ss">docs</span><span class="pp">]</span></span> |
128 | <p>And hit <code>gwj</code> (pretend that the pipe, |, is your cursor):</p> | 175 | <span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a><span class="ex">~/worktrees/rustc/is-ascii-octdigit</span> bc57be3af7a <span class="pp">[</span><span class="ss">feature/is</span><span class="pp">-</span><span class="ss">ascii</span><span class="pp">-</span><span class="ss">octdigit</span><span class="pp">]</span></span></code></pre></div> |
129 | <div class="sourceCode" id="cb9"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> gwj</span> | 176 | <p>And hit <code>gwj</code> (pretend that the pipe, |, is your |
177 | cursor):</p> | ||
178 | <div class="sourceCode" id="cb9"><pre | ||
179 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> gwj</span> | ||
130 | <span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="op">></span> <span class="kw">|</span></span> | 180 | <span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="op">></span> <span class="kw">|</span></span> |
131 | <span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">4/4</span></span> | 181 | <span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">4/4</span></span> |
132 | <span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a><span class="op">></span> ~/worktrees/rustc/master <span class="ex">eac6c33bc63</span> [master]</span> | 182 | <span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a><span class="op">></span> ~/worktrees/rustc/master <span class="ex">eac6c33bc63</span> <span class="pp">[</span><span class="ss">master</span><span class="pp">]</span></span> |
133 | <span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">~/worktrees/rustc/improve-std-char-docs</span> 94cba88553e [improve-std-char-docs]</span> | 183 | <span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">~/worktrees/rustc/improve-std-char-docs</span> 94cba88553e <span class="pp">[</span><span class="ss">improve</span><span class="pp">-</span><span class="ss">std</span><span class="pp">-</span><span class="ss">char</span><span class="pp">-</span><span class="ss">docs</span><span class="pp">]</span></span> |
134 | <span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">~/worktrees/rustc/is-ascii-octdigit</span> bc57be3af7a [feature/is-ascii-octdigit]</span></code></pre></div> | 184 | <span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">~/worktrees/rustc/is-ascii-octdigit</span> bc57be3af7a <span class="pp">[</span><span class="ss">feature/is</span><span class="pp">-</span><span class="ss">ascii</span><span class="pp">-</span><span class="ss">octdigit</span><span class="pp">]</span></span></code></pre></div> |
135 | <p>Approximately type in your branch of choice:</p> | 185 | <p>Approximately type in your branch of choice:</p> |
136 | <div class="sourceCode" id="cb10"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> gwj</span> | 186 | <div class="sourceCode" id="cb10"><pre |
187 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> gwj</span> | ||
137 | <span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="op">></span> docs<span class="kw">|</span></span> | 188 | <span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="op">></span> docs<span class="kw">|</span></span> |
138 | <span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">4/4</span></span> | 189 | <span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">4/4</span></span> |
139 | <span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="op">></span> ~/worktrees/rustc/improve-std-char-docs <span class="ex">94cba88553e</span> [improve-std-char-docs]</span></code></pre></div> | 190 | <span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="op">></span> ~/worktrees/rustc/improve-std-char-docs <span class="ex">94cba88553e</span> <span class="pp">[</span><span class="ss">improve</span><span class="pp">-</span><span class="ss">std</span><span class="pp">-</span><span class="ss">char</span><span class="pp">-</span><span class="ss">docs</span><span class="pp">]</span></span></code></pre></div> |
140 | <p>And hit enter. You should find yourself in the selected worktree.</p> | 191 | <p>And hit enter. You should find yourself in the selected worktree.</p> |
141 | <p>Onward, to the next fault, lack of preview-bility. We can utilize fzf’s aptly named <code>--preview</code> flag, to, well, preview our worktree before performing a selection:</p> | 192 | <p>Onward, to the next fault, lack of preview-bility. We can utilize |
142 | <div class="sourceCode" id="cb11"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="fu">gwj ()</span> <span class="kw">{</span></span> | 193 | fzf’s aptly named <code>--preview</code> flag, to, well, preview our |
194 | worktree before performing a selection:</p> | ||
195 | <div class="sourceCode" id="cb11"><pre | ||
196 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="fu">gwj ()</span> <span class="kw">{</span></span> | ||
143 | <span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">local</span> <span class="va">out</span></span> | 197 | <span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">local</span> <span class="va">out</span></span> |
144 | <span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="va">out</span><span class="op">=</span><span class="va">$(</span></span> | 198 | <span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="va">out</span><span class="op">=</span><span class="va">$(</span></span> |
145 | <span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">git</span> worktree list <span class="kw">|</span></span> | 199 | <span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">git</span> worktree list <span class="kw">|</span></span> |
@@ -148,8 +202,10 @@ aa857eb953e Auto merge of #100537 - petrochenkov:pic ... | |||
148 | <span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a> <span class="va">)</span></span> | 202 | <span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a> <span class="va">)</span></span> |
149 | <span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a> <span class="bu">cd</span> <span class="va">$out</span></span> | 203 | <span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a> <span class="bu">cd</span> <span class="va">$out</span></span> |
150 | <span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a><span class="kw">}</span></span></code></pre></div> | 204 | <span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a><span class="kw">}</span></span></code></pre></div> |
151 | <p>Once again, hit <code>gwj</code> inside a git repository with linked worktrees:</p> | 205 | <p>Once again, hit <code>gwj</code> inside a git repository with linked |
152 | <div class="sourceCode" id="cb12"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> gwj</span> | 206 | worktrees:</p> |
207 | <div class="sourceCode" id="cb12"><pre | ||
208 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> gwj</span> | ||
153 | <span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="ex">╭─────────────────────────────────────────────────────────╮</span></span> | 209 | <span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="ex">╭─────────────────────────────────────────────────────────╮</span></span> |
154 | <span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a><span class="ex">│</span> eac6c33bc63 Auto merge of 100869 nnethercote:replace... │</span> | 210 | <span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a><span class="ex">│</span> eac6c33bc63 Auto merge of 100869 nnethercote:replace... │</span> |
155 | <span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="ex">│</span> b32223fec10 Auto merge of 100707 dzvon:fix-typo, r=d... │</span> | 211 | <span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="ex">│</span> b32223fec10 Auto merge of 100707 dzvon:fix-typo, r=d... │</span> |
@@ -167,9 +223,16 @@ aa857eb953e Auto merge of #100537 - petrochenkov:pic ... | |||
167 | <span id="cb12-16"><a href="#cb12-16" aria-hidden="true" tabindex="-1"></a><span class="op">></span> /home/np/worktrees/compiler/master <span class="ex">eac6c...</span></span> | 223 | <span id="cb12-16"><a href="#cb12-16" aria-hidden="true" tabindex="-1"></a><span class="op">></span> /home/np/worktrees/compiler/master <span class="ex">eac6c...</span></span> |
168 | <span id="cb12-17"><a href="#cb12-17" aria-hidden="true" tabindex="-1"></a> <span class="ex">/home/np/worktrees/compiler/improve-std-char-docs</span> 94cba...</span> | 224 | <span id="cb12-17"><a href="#cb12-17" aria-hidden="true" tabindex="-1"></a> <span class="ex">/home/np/worktrees/compiler/improve-std-char-docs</span> 94cba...</span> |
169 | <span id="cb12-18"><a href="#cb12-18" aria-hidden="true" tabindex="-1"></a> <span class="ex">/home/np/worktrees/compiler/is-ascii-octdigit</span> bc57b...</span></code></pre></div> | 225 | <span id="cb12-18"><a href="#cb12-18" aria-hidden="true" tabindex="-1"></a> <span class="ex">/home/np/worktrees/compiler/is-ascii-octdigit</span> bc57b...</span></code></pre></div> |
170 | <p>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 <code>gwj</code>, browse through your worktrees, preview each one and automatically <code>cd</code> to your selection. But we are not done yet.</p> | 226 | <p>A fancy preview of the last 10 commits on the branch that the |
171 | <p>The last fault was lack shell completions. A quick review of what a shell completion really does:</p> | 227 | selected worktree corresponds to. In other words, sight for sore eyes. |
172 | <div class="sourceCode" id="cb13"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git checkout f<span class="op"><</span>tab<span class="op">></span></span> | 228 | Our little script is already shaping up to be useful, you hit |
229 | <code>gwj</code>, browse through your worktrees, preview each one and | ||
230 | automatically <code>cd</code> to your selection. But we are not done | ||
231 | yet.</p> | ||
232 | <p>The last fault was lack shell completions. A quick review of what a | ||
233 | shell completion really does:</p> | ||
234 | <div class="sourceCode" id="cb13"><pre | ||
235 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git checkout f<span class="op"><</span>tab<span class="op">></span></span> | ||
173 | <span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="ex">feature/is-ascii-octdigit</span></span> | 236 | <span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="ex">feature/is-ascii-octdigit</span></span> |
174 | <span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="ex">fix/some-error</span></span> | 237 | <span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="ex">fix/some-error</span></span> |
175 | <span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="ex">format-doc-tests</span></span> | 238 | <span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="ex">format-doc-tests</span></span> |
@@ -177,16 +240,22 @@ aa857eb953e Auto merge of #100537 - petrochenkov:pic ... | |||
177 | <span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git checkout feat<span class="op"><</span>tab<span class="op">></span></span> | 240 | <span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git checkout feat<span class="op"><</span>tab<span class="op">></span></span> |
178 | <span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a></span> | 241 | <span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a></span> |
179 | <span id="cb13-8"><a href="#cb13-8" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git checkout feature/is-ascii-octdigit</span></code></pre></div> | 242 | <span id="cb13-8"><a href="#cb13-8" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> git checkout feature/is-ascii-octdigit</span></code></pre></div> |
180 | <p>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.</p> | 243 | <p>Each time you hit “tab”, the shell produces a few “completion |
181 | <p>fzf narrows down your options as you type into the prompt, but you still have to:</p> | 244 | candidates”, and once you have just a single candidate left, the shell |
245 | inserts that for you directly into your edit line. Of course, this | ||
246 | process varies from shell to shell.</p> | ||
247 | <p>fzf narrows down your options as you type into the prompt, but you | ||
248 | still have to:</p> | ||
182 | <ol type="1"> | 249 | <ol type="1"> |
183 | <li>Type <code>gwj</code></li> | 250 | <li>Type <code>gwj</code></li> |
184 | <li>Hit enter</li> | 251 | <li>Hit enter</li> |
185 | <li>Type out a query and narrow down your search</li> | 252 | <li>Type out a query and narrow down your search</li> |
186 | <li>Hit enter</li> | 253 | <li>Hit enter</li> |
187 | </ol> | 254 | </ol> |
188 | <p>We can speed that up a bit, have fzf narrow down the candidates on startup, just like our shell does:</p> | 255 | <p>We can speed that up a bit, have fzf narrow down the candidates on |
189 | <div class="sourceCode" id="cb14"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="fu">gwj ()</span> <span class="kw">{</span></span> | 256 | startup, just like our shell does:</p> |
257 | <div class="sourceCode" id="cb14"><pre | ||
258 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="fu">gwj ()</span> <span class="kw">{</span></span> | ||
190 | <span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">local</span> <span class="va">out</span> <span class="va">query</span></span> | 259 | <span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">local</span> <span class="va">out</span> <span class="va">query</span></span> |
191 | <span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a> <span class="va">query</span><span class="op">=</span><span class="st">"</span><span class="va">${1</span><span class="op">:-</span> <span class="va">}</span><span class="st">"</span></span> | 260 | <span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a> <span class="va">query</span><span class="op">=</span><span class="st">"</span><span class="va">${1</span><span class="op">:-</span> <span class="va">}</span><span class="st">"</span></span> |
192 | <span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a> <span class="va">out</span><span class="op">=</span><span class="va">$(</span></span> | 261 | <span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a> <span class="va">out</span><span class="op">=</span><span class="va">$(</span></span> |
@@ -196,8 +265,12 @@ aa857eb953e Auto merge of #100537 - petrochenkov:pic ... | |||
196 | <span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a> <span class="va">)</span></span> | 265 | <span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a> <span class="va">)</span></span> |
197 | <span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a> <span class="bu">cd</span> <span class="va">$out</span></span> | 266 | <span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a> <span class="bu">cd</span> <span class="va">$out</span></span> |
198 | <span id="cb14-10"><a href="#cb14-10" aria-hidden="true" tabindex="-1"></a><span class="kw">}</span></span></code></pre></div> | 267 | <span id="cb14-10"><a href="#cb14-10" aria-hidden="true" tabindex="-1"></a><span class="kw">}</span></span></code></pre></div> |
199 | <p>The change is extremely tiny, blink-and-you’ll-miss-it kinda tiny. We added a little <code>--query</code> flag, that allows you to prefill the prompt, and the <code>-1</code> flag, that avoids the interactive finder if only one match exists on startup:</p> | 268 | <p>The change is extremely tiny, blink-and-you’ll-miss-it kinda tiny. We |
200 | <div class="sourceCode" id="cb15"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="co"># skip through the fzf prompt:</span></span> | 269 | added a little <code>--query</code> flag, that allows you to prefill the |
270 | prompt, and the <code>-1</code> flag, that avoids the interactive finder | ||
271 | if only one match exists on startup:</p> | ||
272 | <div class="sourceCode" id="cb15"><pre | ||
273 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="co"># skip through the fzf prompt:</span></span> | ||
201 | <span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> gwj master</span> | 274 | <span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="ex">λ</span> gwj master</span> |
202 | <span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="co"># cd -- ~/worktrees/rustc/master</span></span> | 275 | <span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="co"># cd -- ~/worktrees/rustc/master</span></span> |
203 | <span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a></span> | 276 | <span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a></span> |
@@ -212,8 +285,11 @@ aa857eb953e Auto merge of #100537 - petrochenkov:pic ... | |||
212 | <span id="cb15-13"><a href="#cb15-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">2/2</span></span> | 285 | <span id="cb15-13"><a href="#cb15-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">2/2</span></span> |
213 | <span id="cb15-14"><a href="#cb15-14" aria-hidden="true" tabindex="-1"></a><span class="op">></span> /home/np/worktrees/compiler/improve-const-perf <span class="ex">eac6c...</span></span> | 286 | <span id="cb15-14"><a href="#cb15-14" aria-hidden="true" tabindex="-1"></a><span class="op">></span> /home/np/worktrees/compiler/improve-const-perf <span class="ex">eac6c...</span></span> |
214 | <span id="cb15-15"><a href="#cb15-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">/home/np/worktrees/compiler/improve-std-char-docs</span> 94cba...</span></code></pre></div> | 287 | <span id="cb15-15"><a href="#cb15-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">/home/np/worktrees/compiler/improve-std-char-docs</span> 94cba...</span></code></pre></div> |
215 | <p>Throw some error handling in there, hook up a similar script to improve the UX of <code>git worktree remove</code>, go wild. A few more helpers I’ve got:</p> | 288 | <p>Throw some error handling in there, hook up a similar script to |
216 | <div class="sourceCode" id="cb16"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="co"># gwa /path/to/branch-name</span></span> | 289 | improve the UX of <code>git worktree remove</code>, go wild. A few more |
290 | helpers I’ve got:</p> | ||
291 | <div class="sourceCode" id="cb16"><pre | ||
292 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="co"># gwa /path/to/branch-name</span></span> | ||
217 | <span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a><span class="co"># creates a new branch and "switches" to it</span></span> | 293 | <span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a><span class="co"># creates a new branch and "switches" to it</span></span> |
218 | <span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a><span class="kw">function</span><span class="fu"> gwa ()</span> <span class="kw">{</span></span> | 294 | <span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a><span class="kw">function</span><span class="fu"> gwa ()</span> <span class="kw">{</span></span> |
219 | <span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">git</span> worktree add <span class="st">"</span><span class="va">$1</span><span class="st">"</span> <span class="kw">&&</span> <span class="bu">cd</span> <span class="st">"</span><span class="va">$1</span><span class="st">"</span></span> | 295 | <span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">git</span> worktree add <span class="st">"</span><span class="va">$1</span><span class="st">"</span> <span class="kw">&&</span> <span class="bu">cd</span> <span class="st">"</span><span class="va">$1</span><span class="st">"</span></span> |