From 560a40492e1954d19f4528d58c2f45b07379cff5 Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 8 May 2024 11:40:31 +0100 Subject: new post: snip snap --- docs/index.xml | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 2 deletions(-) (limited to 'docs/index.xml') diff --git a/docs/index.xml b/docs/index.xml index eb43379..046b4d2 100644 --- a/docs/index.xml +++ b/docs/index.xml @@ -12,6 +12,79 @@ en-us Creative Commons BY-NC-SA 4.0 +Snip Snap +<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# &quot; switch to alternate buffer (same as Ctrl+^) +:vsp# &quot; create a vertical split with the alternate buffer +:read# &quot; read contents of alternate buffer into current buffer +:!wc # &quot; 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>&lt;prefix&gt;+shift+L</code>.</p> +<h4 id="qutebrowser">qutebrowser</h4> +<p>Switch to the last active tab with <code>g$</code>.</p> +https://peppe.rs/posts/snip_snap/ +Wed, 08 May 2024 10:38:00 +0000 +https://peppe.rs/posts/snip_snap/ + + Plain Text Journaling <p>I cobbled together a journaling system with {neo,}vim, coreutils and <a href="http://www.fresse.org/dateutils">dateutils</a>. This system is @@ -1014,10 +1087,10 @@ class="sourceCode bash"><code class="sourceCode bash"><span id="cb20 your dependencies:</p> <div class="sourceCode" id="cb21"><pre class="sourceCode toml"><code class="sourceCode toml"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="co"># within Cargo.toml</span></span> -<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a><span class="kw">[</span><span class="dt">dependencies</span><span class="kw">]</span></span> +<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a><span class="kw">[dependencies]</span></span> <span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a><span class="dt">tree-sitter</span> <span class="op">=</span> <span class="st">&quot;0.20&quot;</span></span> <span id="cb21-4"><a href="#cb21-4" aria-hidden="true" tabindex="-1"></a></span> -<span id="cb21-5"><a href="#cb21-5" aria-hidden="true" tabindex="-1"></a><span class="kw">[</span><span class="dt">dependencies</span><span class="kw">.</span><span class="dt">tree-sitter-rust</span><span class="kw">]</span></span> +<span id="cb21-5"><a href="#cb21-5" aria-hidden="true" tabindex="-1"></a><span class="kw">[dependencies.tree-sitter-rust]</span></span> <span id="cb21-6"><a href="#cb21-6" aria-hidden="true" tabindex="-1"></a><span class="dt">git</span> <span class="op">=</span> <span class="st">&quot;https://github.com/tree-sitter/tree-sitter-rust&quot;</span></span></code></pre></div> <p>Let’s load in some Rust code to work with. As <a href="https://en.wikipedia.org/wiki/Self-reference">an ode to Gödel</a> -- cgit v1.2.3