Created
November 29, 2024 21:43
-
-
Save rnemeth90/b787943dfb410be190f6f240a4de0e15 to your computer and use it in GitHub Desktop.
Tmux Basics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## `tmux` Basics | |
### Installation | |
- https://github.com/tmux/tmux/wiki/Installing | |
### Note | |
- In the official tmux documentation (`man tmux`), key `C` is Ctrl and `M` is Alt. | |
- [Complete Getting Started Guide](https://github.com/tmux/tmux/wiki/Getting-Started) | |
### Commands | |
These are run in the terminal outside `tmux` | |
| Command | Description | | |
|---------------------------------------- |---------------------------------------- | | |
| `tmux` | Starts a tmux session | | |
| `tmux new -s <SESSION NAME>` | Starts a named tmux session | | |
| `tmux ls` | List all active tmux sessions | | |
| `tmux kill -session -t <SESSION NAME>` | Kill a tmux session | | |
| `tmux attach <SESSION NUMBER>` | Attach to session using session number | | |
| `tmux attach -t <SESSION NAME>` | Attach to a session using session name | | |
### General - Keyboard Shortcuts | |
| Shortcut | Description | | |
|-------------------------- |-------------------------------------------- | | |
| `CTRL + B ?` | Show all tmux shortcuts | | |
| `CTRL + B w` | Navigate / browse tmux sessions and windows | | |
| `CTRL + B d` | Detach from current session | | |
### Panes - Keyboard Shortcuts | |
| Shortcut | Description | | |
|-------------------------- |------------------------------------ | | |
| `CTRL + B + <ARROW KEY>` | Resize currently active pane | | |
| `CTRL + B <ARROW KEY>` | Switch active pane | | |
| `CTRL + B %` | Split current pane vertically | | |
| `CTRL + B "` | Split current pane horizontally | | |
| `CTRL + B SPACEBAR` | Switch current pane orientation | | |
| `CTRL + B z` | Full screen a pane | | |
### Window Control - Keyboard Shortcuts | |
| Shortcut | Description | | |
|--------------------------- |------------------------------------------ | | |
| `CTRL + B c` | Create new window | | |
| `tmux rename-window <NAME>` | Rename the current window | | |
| `CTRL + B w` | List and choose specific window and pane | | |
| `CTRL + B ,` | Go to named window | | |
| `CTRL + B n` | Go to next window | | |
| `CTRL + B p` | Go to previous window | | |
### Copy/Paste - Keyboard Shortcuts | |
| Shortcut | Description | | |
|-------------------------- |--------------------------------------------------------- | | |
| `CTRL + B [` | Enter copy mode | | |
| `CTRL + SPACEBAR` | Select text in copy mode | | |
| `ALT + W` | Confirm text selection in copy mode (Will exit copy mode) | | |
| `CTRL + c` | Exit copy mode | | |
| `CTRL + B ]` | Paste copied text | | |
### Organization | |
These commands can be run within `tmux` | |
| Shortcut | Description | | |
|------------------------------------------------- |-------------------------------------------- | | |
| `tmux rename-session` | Rename current session | | |
| `tmux rename-window` | Rename current window | | |
| `tmux swap-window -s <WIN INDEX> -t <WIN INDEX>` | Swap window positions | | |
| `tmux move-window -s <SES>:<WIN> -t <SES>:<WIN>` | Move a window to another session | | |
| `tmux move-pane -s <SES>:<WIN> -t <SES>:<WIN>` | Move a pane to another window | | |
------ | |
### Plugins and Configurations (`~/.tmux.conf`) | |
1. Add `tmux` configuration file `.tmux.conf` to home directory (ie. `~/.tmux.conf`) | |
2. Install Tmux Package manager | |
- Run in terminal: | |
- `git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm` | |
- Add at END of `.tmux.conf`: | |
- `set -g @plugin 'tmux-plugins/tpm'` | |
- `run '~/.tmux/plugins/tpm/tpm'` | |
2. Add plugins into configuration file | |
- Example: `set -g @plugin 'tmux-plugins/tmux-resurrect'` (Adding tmux-resurrect plugin) | |
- Example: `set -g @plugin 'tmux-plugins/tmux-yank'` (Adding tmux-yank plugin) | |
3. Add configurations | |
- Example: `set -g mouse on` (Turn on mouse mode) | |
4. After changing `tmux.conf`, still in `tmux` press `CTRL + B I` to refresh and install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment