blob: fa61fe2058fdc2a21c993410bc2be4459edcc73c (
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
|
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:
```bash
$ 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`:
```bash
~/foo $ cd ~/bar
~/bar $ cd -
~/foo $
```
This is especially handy in combination with my [git-worktree
flow](../curing_a_case_of_git-UX/):
```bash
~/main-branch $ gwj feature
~/feat-branch $ cd -
~/main-branch $
```
#### bash - jobs
I often suspend multiple `vim` sessions with `Ctrl-Z`:
```bash
$ 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`:
```bash
$ fg
```
With a job identifier:
```bash
$ fg %2 # resumes interactive git commit
```
Or switch to "last" job, or the second-most-recently-resumed
job:
```bash
$ 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:
```vimscript
: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$`.
|