## Tmux Notes #### Quick Summary If a command/keybinding starts with a colon `:` assume that a prefix precedes it. Usually the default prefix is `Ctrl + b` but can be different if set to something else. To set a different prefix put the following into tmux.conf: ```bash # Setting the prefix from C-b to C-s unbind C-b set -g prefix C-s # Ensure that we can send Ctrl + S to other apps bind C-s send-prefix ``` #### Basic commands/keys * Enter command mode ` :` * List keybindings $ `tmux list-keys` `:list-keys` ` ?` * Close current pane $ `exit` ` x` - - - #### Plugins * Installing plugins ` I` then reload tmux environment with either: $ `tmux source ~/.tmux.conf` or if tmux config is in a XDG config base directory $ `tmux source ~/.config/tmux/tmux.conf` or use this keybinding ` r` * Plugin uninstall Delete or comment out the plugin in .tmux.conf Then save and reload - - - #### Panes #### PANES * Toggle last active pane ` ;` * Split pane horizontally ` %` * Split pane vertically ` "` * Move the current pane left ` {` * Move the current pane right ` }` * Switch to another pane depending on it's direction ` ` ` ` ` ` ` ` * Toggle synchronize-panes(send command to all panes) `:setw synchronize-panes` * Switch to next pane ` o` * Show pane numbers ` q` * Switch/select pane by number ` q 0 ... 9` * Resize current pane height ` Ctrl + ` ` Ctrl + ` * Resize current pane width ` Ctrl + ` ` Ctrl + ` * move current pane up or anti-clockwise `:swap-pane -U` * move current pane down or clockwise `:swap-pane -D` * move current pane to the left ` {` `:swap-pane -L` * move current pane to the right ` }` `:swap-pane -R` * show pane numbers (type number to move cursor) ` q` * toggle pane arrangements/layouts ` ` * Toggle pane zoom ` z` * Convert pane into a window ` !` * Close current pane ` x` or just type $ `exit` - - - #### WINDOWS * Start a new session with the name ***mysession*** and window ***mywindow*** $ `tmux new -s mysession -n mywindow` * Create window ` c` * Rename current window ` ,` * Previous window ` p` * Next window ` n` * rotate window ` Ctrl + o` * Move(cycle) cursor to next window ` o` * Switch/select window by number ` 0 ... 9` * Reorder window, swap window number 2(src) and 1(dst) `:swap-window -s 2 -t 1` * Move current window to the left by one position `:swap-window -t -1` * Close Window ` &` `:kill-window` - - - #### SESSIONS * Start a new session $ `tmux` $ `tmux new` $ `tmux new-session` ` :new` * Start a new session with the name ***mysession*** $ `tmux new -s mysession` ` :new -s mysession` * Kill/delete session ***mysession*** $ `tmux kill-ses -t mysession` $ `tmux kill-session -t mysession` * Kill/delete all sessions but the current $ `tmux kill-session -a` * Kill/delete all sessions but ***mysession*** $ `tmux kill-session -a -t mysession` * Rename session ` $` * Detach from session ` d` * Detach others on the session (Maximize window by detaching other clients) `:attach -d` * Show all sessions $ `tmux ls` $ `tmux list-sessions` ` s` * Attach to last session $ `tmux a` $ `tmux at` $ `tmux attach` $ `tmux attach-session` * Attach to a session with the name ***mysession*** $ `tmux a -t mysession` $ `tmux at -t mysession` $ `tmux attach -t mysession` $ `tmux attach-session -t mysession` * Move to previous session ` (` * Move to next session ` )` - - - #### SSH * Make sure ssh is setup and use this command on the remote-machine `$ tmux new-session -s pair` * Connect to the remote tmux session `$ ssh -t user@remote-machine tmux attach-session -t pair` - - - #### Copy Mode * Use vi keys `:setw -g mode-keys vi` or put this into tmux.conf: ```bash set-window-option -g mode-keys vi ``` * Enter copy mode ` [` * Enter copy mode and scroll one page up ` ` * Quit mode `` * Go to top line `` * Go to bottom line `` * Scroll up `` * Scroll down `` * Move cursor left `` * Move cursor down `` * Move cursor up `` * Move cursor right `` * Move cursor forward one word at a time `` * Move cursor backward one word at a time `` * Search forward `` * Search backward `` * Next keyword occurance `` * Previous keyword occurance `` * Start selection `` * Clear selection `` * Copy selection `` * Paste contents of buffer_0 ` ]` * Display buffer_0 contents `:show-buffer` * Copy entire visible contents of pane to a buffer `:capture-pane` * Show all buffers `:list-buffers` * Show all buffers and paste selected `:choose-buffer` * Save buffer contents to buf.txt `:save-buffer buf.txt` * Delete buffer_1 `:delete-buffer -b 1` - - - #### MISC * Enter command mode ` :` * Set OPTION for all sessions `:set -g OPTION` * Set OPTION for all windows `:setw -g OPTION` * Enable mouse mode `:set mouse on` * Show time ` t` - - - #### HELP * List key bindings(shortcuts) $ `tmux list-keys` `:list-keys` ` ?` * Show every session, window, pane, etc... $ `tmux info` - - -