blob: 02fa6742e92b4137269118f869deb2f39c4b2178 (
plain)
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
|
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="/syntax.css">
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1">
<meta content="#ffffff" name="theme-color">
<meta name="HandheldFriendly" content="true">
<meta property="og:title" content="Snip Snap">
<meta property="og:type" content="website">
<meta property="og:description" content="a static site {for, by, about} me ">
<meta property="og:url" content="https://peppe.rs">
<link rel="icon" type="image/x-icon" href="/favicon.png">
<title>Snip Snap · peppe.rs</title>
<body>
<div class="posts">
<div class="post">
<a href="/" class="post-end-link">Home</a>
<span>/</span>
<a href="/posts" class="post-end-link">Posts</a>
<span>/</span>
<a class="post-end-link">Snip Snap</a>
<a class="stats post-end-link" href="https://git.peppe.rs/web/site/plain/posts/snip_snap.md
">View Raw</a>
<div class="separator"></div>
<div class="date">
08/05 — 2024
<div class="stats">
<span class="stats-number">
40.76
</span>
<span class="stats-unit">cm</span>
 
<span class="stats-number">
2.1
</span>
<span class="stats-unit">min</span>
</div>
</div>
<h1>
Snip Snap
</h1>
<div class="post-text">
<p>I regularly switch between exactly two things while working, a
“current” and an “alternate” item; a lot of tools I use seem to support
this flow.</p>
<h4 id="git">git</h4>
<p>Pass <code>-</code> to <code>git-checkout</code> to switch to the
previously active branch:</p>
<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="ex">$</span> git branch</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="ex">*</span> foo</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">bar</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> git checkout bar</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> git branch</span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">foo</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="ex">*</span> bar</span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> git checkout <span class="at">-</span></span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> git branch</span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a><span class="ex">*</span> foo</span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">bar</span></span></code></pre></div>
<h4 id="bash---cd">bash - cd</h4>
<p>This may not be exclusive to <code>bash</code>:</p>
<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="ex">~/foo</span> $ cd ~/bar</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="ex">~/bar</span> $ cd <span class="at">-</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="ex">~/foo</span> $</span></code></pre></div>
<p>This is especially handy in combination with my <a
href="../curing_a_case_of_git-UX/">git-worktree flow</a>:</p>
<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="ex">~/main-branch</span> $ gwj feature</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ex">~/feat-branch</span> $ cd <span class="at">-</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">~/main-branch</span> $</span></code></pre></div>
<h4 id="bash---jobs">bash - jobs</h4>
<p>I often suspend multiple <code>vim</code> sessions with
<code>Ctrl-Z</code>:</p>
<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> jobs</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="ex">[1]+</span> Stopped vim transpiler/src/transform.rs</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="ex">[2]-</span> Stopped git commit <span class="at">--verbose</span></span></code></pre></div>
<p>In the above example: I suspended <code>vim</code> when working on
<code>transform.rs</code>, and then began working on a commit by running
<code>git commit</code> without a message flag (lets you craft a message
in <code>$EDITOR</code>). To bring the current job to the foreground,
you can use <code>fg</code>:</p>
<div class="sourceCode" id="cb5"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> fg</span></code></pre></div>
<p>With a job identifier:</p>
<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="ex">$</span> fg %2 <span class="co"># resumes interactive git commit</span></span></code></pre></div>
<p>Or switch to “last” job, or the second-most-recently-resumed job:</p>
<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="ex">$</span> fg %-</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> %- <span class="co"># shorthand</span></span></code></pre></div>
<h4 id="vim">vim</h4>
<p>Switch to the last active buffer with <code>Ctrl+^</code>. In
command-mode, <code>#</code> refers to the last active buffer, you can
use this as an argument to a few commands:</p>
<pre class="vimscript"><code>:b# " switch to alternate buffer (same as Ctrl+^)
:vsp# " create a vertical split with the alternate buffer
:read# " read contents of alternate buffer into current buffer
:!wc # " pass file name of alternate buffer to the command `wc`</code></pre>
<p>See <code>:help c_#</code> for more.</p>
<h4 id="tmux">tmux</h4>
<p>Switch to the last active tmux session with
<code><prefix>+shift+L</code>.</p>
<h4 id="qutebrowser">qutebrowser</h4>
<p>Switch to the last active tab with <code>g$</code>.</p>
</div>
<div class="intro">
Hi.
<div class="hot-links">
<a href="https://peppe.rs/index.xml" class="feed-button">Subscribe</a>
</div>
<p>I'm Akshay, programmer and pixel-artist.</p>
<p>
I write <a href="https://git.peppe.rs">open-source stuff</a> to pass time.
I also design fonts:
<a href="https://git.peppe.rs/fonts/scientifica/about">scientifica</a>,
<a href="https://git.peppe.rs/fonts/curie/about">curie</a>.
</p>
<p>Send me a mail at [email protected] or a message at [email protected].</p>
</div>
<a href="/" class="post-end-link">Home</a>
<span>/</span>
<a href="/posts" class="post-end-link">Posts</a>
<span>/</span>
<a class="post-end-link">Snip Snap</a>
<a class="stats post-end-link" href="https://git.peppe.rs/web/site/plain/posts/snip_snap.md
">View Raw</a>
</div>
</div>
</body>
</html>
|