diff options
Diffstat (limited to 'posts')
-rw-r--r-- | posts/snip_snap.md | 102 |
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 @@ | |||
1 | I regularly switch between exactly two things while working, | ||
2 | a "current" and an "alternate" item; a lot of tools I use | ||
3 | seem to support this flow. | ||
4 | |||
5 | #### git | ||
6 | |||
7 | Pass `-` to `git-checkout` to switch to the previously | ||
8 | active 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 | |||
28 | This may not be exclusive to `bash`: | ||
29 | |||
30 | ```bash | ||
31 | ~/foo $ cd ~/bar | ||
32 | ~/bar $ cd - | ||
33 | ~/foo $ | ||
34 | ``` | ||
35 | |||
36 | This is especially handy in combination with my [git-worktree | ||
37 | flow](../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 | |||
47 | I 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 | |||
55 | In the above example: I suspended `vim` when working on | ||
56 | `transform.rs`, and then began working on a commit by | ||
57 | running `git commit` without a message flag (lets you craft | ||
58 | a message in `$EDITOR`). To bring the current job to the | ||
59 | foreground, you can use `fg`: | ||
60 | |||
61 | ```bash | ||
62 | $ fg | ||
63 | ``` | ||
64 | |||
65 | With a job identifier: | ||
66 | |||
67 | ```bash | ||
68 | $ fg %2 # resumes interactive git commit | ||
69 | ``` | ||
70 | |||
71 | Or switch to "last" job, or the second-most-recently-resumed | ||
72 | job: | ||
73 | |||
74 | ```bash | ||
75 | $ fg %- | ||
76 | $ %- # shorthand | ||
77 | |||
78 | ``` | ||
79 | |||
80 | #### vim | ||
81 | |||
82 | Switch to the last active buffer with `Ctrl+^`. In | ||
83 | command-mode, `#` refers to the last active buffer, you can | ||
84 | use 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 | |||
93 | See `:help c_#` for more. | ||
94 | |||
95 | #### tmux | ||
96 | |||
97 | Switch to the last active tmux session with | ||
98 | `<prefix>+shift+L`. | ||
99 | |||
100 | #### qutebrowser | ||
101 | |||
102 | Switch to the last active tab with `g$`. | ||