Home / Posts / Snip Snap View Raw
08/05 — 2024
40.76 cm   2.1 min

Snip Snap

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.

git

Pass - to git-checkout to switch to the previously active branch:

$ git branch
* foo
  bar

$ git checkout bar
$ git branch
  foo
* bar

$ git checkout -
$ git branch
* foo
  bar

bash - cd

This may not be exclusive to bash:

~/foo $ cd ~/bar
~/bar $ cd -
~/foo $

This is especially handy in combination with my git-worktree flow:

~/main-branch $ gwj feature
~/feat-branch $ cd -
~/main-branch $

bash - jobs

I often suspend multiple vim sessions with Ctrl-Z:

$ jobs
[1]+  Stopped                 vim transpiler/src/transform.rs
[2]-  Stopped                 git commit --verbose

In the above example: I suspended vim when working on transform.rs, and then began working on a commit by running git commit without a message flag (lets you craft a message in $EDITOR). To bring the current job to the foreground, you can use fg:

$ fg

With a job identifier:

$ fg %2    # resumes interactive git commit

Or switch to “last” job, or the second-most-recently-resumed job:

$ fg %-
$ %-      # shorthand

vim

Switch to the last active buffer with Ctrl+^. In command-mode, # refers to the last active buffer, you can use this as an argument to a few commands:

: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`

See :help c_# for more.

tmux

Switch to the last active tmux session with <prefix>+shift+L.

qutebrowser

Switch to the last active tab with g$.

Hi.

I'm Akshay, programmer and pixel-artist.

I write open-source stuff to pass time. I also design fonts: scientifica, curie.

Send me a mail at [email protected] or a message at [email protected].

Home / Posts / Snip Snap View Raw