aboutsummaryrefslogtreecommitdiff
path: root/posts
diff options
context:
space:
mode:
authorAkshay <[email protected]>2024-05-08 11:40:31 +0100
committerAkshay <[email protected]>2024-05-08 11:40:31 +0100
commit560a40492e1954d19f4528d58c2f45b07379cff5 (patch)
tree168dcf6eaf972fda5ba16731ecb60adf5af1b838 /posts
parent66c2d86d45b32297ba33606bd1f88c3d56c97716 (diff)
new post: snip snapHEADmaster
Diffstat (limited to 'posts')
-rw-r--r--posts/snip_snap.md102
1 files changed, 102 insertions, 0 deletions
diff --git a/posts/snip_snap.md b/posts/snip_snap.md
new file mode 100644
index 0000000..fa61fe2
--- /dev/null
+++ b/posts/snip_snap.md
@@ -0,0 +1,102 @@
1I regularly switch between exactly two things while working,
2a "current" and an "alternate" item; a lot of tools I use
3seem to support this flow.
4
5#### git
6
7Pass `-` to `git-checkout` to switch to the previously
8active branch:
9
10```bash
11$ git branch
12* foo
13 bar
14
15$ git checkout bar
16$ git branch
17 foo
18* bar
19
20$ git checkout -
21$ git branch
22* foo
23 bar
24```
25
26#### bash - cd
27
28This may not be exclusive to `bash`:
29
30```bash
31~/foo $ cd ~/bar
32~/bar $ cd -
33~/foo $
34```
35
36This is especially handy in combination with my [git-worktree
37flow](../curing_a_case_of_git-UX/):
38
39```bash
40~/main-branch $ gwj feature
41~/feat-branch $ cd -
42~/main-branch $
43```
44
45#### bash - jobs
46
47I often suspend multiple `vim` sessions with `Ctrl-Z`:
48
49```bash
50$ jobs
51[1]+ Stopped vim transpiler/src/transform.rs
52[2]- Stopped git commit --verbose
53```
54
55In the above example: I suspended `vim` when working on
56`transform.rs`, and then began working on a commit by
57running `git commit` without a message flag (lets you craft
58a message in `$EDITOR`). To bring the current job to the
59foreground, you can use `fg`:
60
61```bash
62$ fg
63```
64
65With a job identifier:
66
67```bash
68$ fg %2 # resumes interactive git commit
69```
70
71Or switch to "last" job, or the second-most-recently-resumed
72job:
73
74```bash
75$ fg %-
76$ %- # shorthand
77
78```
79
80#### vim
81
82Switch to the last active buffer with `Ctrl+^`. In
83command-mode, `#` refers to the last active buffer, you can
84use this as an argument to a few commands:
85
86```vimscript
87:b# " switch to alternate buffer (same as Ctrl+^)
88:vsp# " create a vertical split with the alternate buffer
89:read# " read contents of alternate buffer into current buffer
90:!wc # " pass file name of alternate buffer to the command `wc`
91```
92
93See `:help c_#` for more.
94
95#### tmux
96
97Switch to the last active tmux session with
98`<prefix>+shift+L`.
99
100#### qutebrowser
101
102Switch to the last active tab with `g$`.