Skip to content

Commit 71a0731

Browse files
committed
edited tmux.md
1 parent 03b4599 commit 71a0731

File tree

1 file changed

+78
-39
lines changed

1 file changed

+78
-39
lines changed

tmux.md

Lines changed: 78 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,109 @@
1-
# tmux shortcuts & cheatsheet
1+
# `tmux` shortcuts & cheatsheet
2+
3+
## `tmux` config file
4+
5+
Located here: `~/.tmux.conf`
6+
7+
`tmux show -g` will show you the current settings. You can write that to the config file with
8+
9+
```bash
10+
tmux show -g > ~/.tmux.conf
11+
```
12+
13+
By modifying the previous command, you can prepend each line with the needed `set-option -g`
14+
15+
__FINAL COMMAND:__
16+
17+
```bash
18+
tmux show -g | sed 's/^/set-option -g /' > ~/.tmux.conf
19+
```
20+
---
21+
22+
## `tmux` commands
223

324
start new:
425

5-
tmux
26+
```bash
27+
tmux
28+
```
629

730
start new with session name:
831

9-
tmux new -s myname
32+
```bash
33+
tmux new -s myname
34+
```
1035

1136
attach:
1237

13-
tmux a # (or at, or attach)
38+
```bash
39+
tmux a # (or at, or attach)
40+
```
1441

1542
attach to named:
1643

17-
tmux a -t myname
44+
```bash
45+
tmux a -t myname
46+
```
1847

1948
list sessions:
2049

21-
tmux ls
50+
```bash
51+
tmux ls
52+
```
2253

23-
<a name="killSessions"></a>kill session:
54+
kill sessions:
2455

25-
tmux kill-session -t myname
56+
```bash
57+
tmux kill-session -t myname
58+
```
2659

27-
<a name="killAllSessions"></a>Kill all the tmux sessions:
60+
kill all sessions:
2861

29-
tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill
62+
```bash
63+
tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill
64+
```
65+
---
3066

31-
In tmux, hit the prefix `ctrl+b` (my modified prefix is ctrl+a) and then:
67+
In `tmux`, hit the prefix <kbd>ctrl</kbd> + <kbd>b</kbd> and then:
3268

3369
## Sessions
3470

3571
:new<CR> new session
36-
s list sessions
37-
$ name session
72+
<kbd>s</kbd> list sessions
73+
<kbd>$</kbd> name session
3874

3975
## Windows (tabs)
4076

41-
c create window
42-
w list windows
43-
n next window
44-
p previous window
45-
f find window
46-
, name window
47-
& kill window
77+
<kbd>c</kbd> create window
78+
<kbd>w</kbd> list windows
79+
<kbd>n</kbd> next window
80+
<kbd>p</kbd> previous window
81+
<kbd>f</kbd> find window
82+
<kbd>,</kbd> name window
83+
<kbd>&</kbd> kill window
4884

4985
## Panes (splits)
5086

51-
% vertical split
52-
" horizontal split
87+
<kbd>%</kbd> vertical split
88+
<kbd>"</kbd> horizontal split
89+
5390

54-
o swap panes
55-
q show pane numbers
56-
x kill pane
57-
+ break pane into window (e.g. to select text by mouse to copy)
58-
- restore pane from window
59-
space - toggle between layouts
60-
<prefix> q (Show pane numbers, when the numbers show up type the key to goto that pane)
61-
<prefix> { (Move the current pane left)
62-
<prefix> } (Move the current pane right)
63-
<prefix> z toggle pane zoom
64-
65-
## <a name="syncPanes"></a>Sync Panes
91+
<kbd>o</kbd> swap panes
92+
<kbd>q</kbd> show pane numbers
93+
<kbd>x</kbd> kill pane
94+
<kbd>+</kbd> break pane into window (e.g. to select text by mouse to copy)
95+
<kbd>-</kbd> restore pane from window
96+
<kbd>⍽</kbd> space - toggle between layouts
97+
<prefix> <kbd>q</kbd> (Show pane numbers, when the numbers show up type the key to goto that pane)
98+
<prefix> <kbd>{</kbd> (Move the current pane left)
99+
<prefix> <kbd>}</kbd> (Move the current pane right)
100+
<prefix> <kbd>z</kbd> toggle pane zoom
101+
102+
## Sync Panes
66103

67104
You can do this by switching to the appropriate window, typing your Tmux prefix (commonly Ctrl-B or Ctrl-A) and then a colon to bring up a Tmux command line, and typing:
68105

69-
```
106+
```bash
70107
:setw synchronize-panes
71108
```
72109

@@ -93,13 +130,15 @@ You can also resize panes if you don’t like the layout defaults. I personally
93130

94131
Pressing PREFIX [ places us in Copy mode. We can then use our movement keys to move our cursor around the screen. By default, the arrow keys work. we set our configuration file to use Vim keys for moving between windows and resizing panes so we wouldn’t have to take our hands off the home row. tmux has a vi mode for working with the buffer as well. To enable it, add this line to .tmux.conf:
95132

96-
setw -g mode-keys vi
133+
```bash
134+
setw -g mode-keys vi
135+
```
97136

98-
With this option set, we can use h, j, k, and l to move around our buffer.
137+
With this option set, we can use <kbd>h</kbd>, <kbd>j</kbd>, <kbd>k</kbd>, and <kbd>l</kbd> to move around our buffer.
99138

100-
To get out of Copy mode, we just press the ENTER key. Moving around one character at a time isn’t very efficient. Since we enabled vi mode, we can also use some other visible shortcuts to move around the buffer.
139+
To get out of Copy mode, we just press the <kbd>ENTER</kbd> key. Moving around one character at a time isn’t very efficient. Since we enabled vi mode, we can also use some other visible shortcuts to move around the buffer.
101140

102-
For example, we can use "w" to jump to the next word and "b" to jump back one word. And we can use "f", followed by any character, to jump to that character on the same line, and "F" to jump backwards on the line.
141+
For example, we can use <kbd>w</kbd> to jump to the next word and <kbd>b</kbd> to jump back one word. And we can use <kbd>f</kbd>, followed by any character, to jump to that character on the same line, and <kbd>F</kbd> to jump backwards on the line.
103142

104143
Function vi emacs
105144
Back to indentation ^ M-m

0 commit comments

Comments
 (0)