cheatsheets/tmux.md

145 lines
2.9 KiB
Markdown
Raw Permalink Normal View History

2013-10-14 02:36:58 +00:00
---
title: tmux
2018-12-06 22:15:40 +00:00
category: CLI
2024-04-08 08:36:29 +00:00
updated: 2024-04-08
2012-03-16 06:14:31 +00:00
---
### Commands
$ tmux
-u # UTF8 mode
-S ~/.tmux.socket
#### Sessions
$ tmux new
$ tmux new -s session_name
$ tmux attach # Default session
$ tmux attach -t session_name
$ tmux switch -t session_name
$ tmux ls # List sessions
$ tmux detach
#### Windows
$ tmux new-window
2012-03-16 06:14:31 +00:00
### Help
C-b ?
### Scrolling
C-b [ # Enter scroll mode then press up and down, you can also scroll with mouse support enabled (`set -g mouse on` in `~/.tmux.conf`)
2012-03-16 06:14:31 +00:00
### Copy/paste
C-b [ # 1. Enter scroll mode first
Space # 2. Start selecting and move around
Enter # 3. Press enter to copy
2012-03-16 06:14:31 +00:00
C-b ] # Paste
### Panes
C-b % # vert
C-b " # horiz
2012-03-16 06:14:31 +00:00
C-b hkjl # navigation
C-b HJKL # resize
C-b o # next window
2020-02-12 14:20:02 +00:00
C-b q # show pane numbers
2012-03-16 06:14:31 +00:00
C-b x # close pane
C-b { or } # move windows around
### Windows
C-b c # New window
C-b 1 # Go to window 1
2019-12-29 03:34:23 +00:00
C-b n # Go to next window
C-b p # Go to previous window
C-b w # List all window
2012-03-16 06:14:31 +00:00
### Detach/attach
2017-10-22 11:08:21 +00:00
C-b d # Detach
2012-03-16 06:14:31 +00:00
C-b ( ) # Switch through sessions
$ tmux attach
### Search in buffer
C-b [ # 1. Enter scroll mode first, you can also scroll with mouse support enabled
C-s # 2. Enter search mode, type pattern then press Enter to start search
n or N # 3. Go to the previous or next match
C-c # 4. Exit search and scroll mode
2012-03-16 06:14:31 +00:00
### Niceties
C-b t # Display a clock, press any key to quit
2015-04-20 07:09:14 +00:00
## Status formats
```
setw -g window-status-format `#[fg=8,bg=default]#I`
```
See `message-command-style` in the man page.
### Attribute/colors
2023-03-13 12:02:33 +00:00
| Key | Description |
| --- | --- |
2015-04-20 07:09:14 +00:00
| `#[fg=1]` | standard color |
| `#[fg=yellow]` | yellow |
| `#[bold]` | bold |
| `#[fg=colour240]` | 256 color |
| `#[fg=default]` | default |
| `#[fg=1,bg=2]` | combinations |
| `#[default]` | reset |
### Colors
* `black` `red` `green` `yellow` `blue` `magenta` `cyan` `white`
* `brightred` (and so on)
* `colour0` ... `colour255`
* `#333` (rgb hex)
### Attributes
* `bold` `underscore` `blink` `noreverse` `hidden` `dim` `italics`
### Variables
2023-03-13 12:02:33 +00:00
| Key | Description |
| --- | --- |
2015-04-20 07:09:14 +00:00
| `#(date)` | shell command |
| `#I` | window index |
| `#S` | session name |
| `#W` | window name |
| `#F` | window flags |
| `#H` | Hostname |
| `#h` | Hostname, short |
| `#D` | pane id |
| `#P` | pane index |
| `#T` | pane title |
## Options
set -g status-justify [left|centre|right]
set -g status-left '...'
setw -g window-status-style
setw -g window-status-activity-style
setw -g window-status-bell-style
setw -g window-status-content-style
setw -g window-status-current-style
setw -g window-status-last-style
setw -g window-status-format
setw -g window-status-current-format
setw -g window-status-separator