diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/tmux.md | 433 |
1 files changed, 229 insertions, 204 deletions
diff --git a/tools/tmux.md b/tools/tmux.md index 2189e0a..90d8b2b 100644 --- a/tools/tmux.md +++ b/tools/tmux.md @@ -1,296 +1,321 @@ ## 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 +`<prefix> :` +* List keybindings +$ `tmux list-keys` +`:list-keys` +`<prefix> ?` +* Close current pane +$ `exit` +`<prefix> x` + +- - - + #### Plugins -* Key bindings for tmux-resurrect -`<prefix> + Ctrl-s` # save changed to 'W' -`<prefix> + Ctrl-r` # restore changed to 'E' * Installing plugins -`<prefix> + I` +`<prefix> 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 +`<prefix> r` * Plugin uninstall Delete or comment out the plugin in .tmux.conf Then save and reload - - - -#### Basic commands/keys -* List keybindings -$ `tmux list-keys` -or -`<prefix>:list-keys` -or -`<prefix>:?` - -* Panes Management -`<prefix>:swap-pane -U` # move current pane up or anti-clockwise -`<prefix>:swap-pane -D` # move current pane down or clockwise -`<prefix>{` or `<prefix>(:swap-pane -L)` # move current pane to the left -`<prefix>}` or `<prefix>(:swap-pane -R)` # move current pane to the right -`<prefix>q` # show pane numbers (type number to move cursor) -`<prefix><Space>` # toggle pane arrangements -`<prefix>Ctrl-o` # rotate window -* Move cursor to next window -`<prefix>o` +#### Panes +#### PANES +* Toggle last active pane +`<prefix> ;` -* Close Window -`<prefix>&` or `<prefix>:kill-window` # kill window -- - - -#### SESSIONS -* Start a new session -$ `tmux` -$ `tmux new` -$ `tmux new-session` -`<prefix>:new` +* Split pane horizontally +`<prefix> %` -* Start a new session with the name ***mysession*** -$ `tmux new -s mysession` -`<prefix>:new -s mysession` +* Split pane vertically +`<prefix> "` -* Kill/delete session mysession -$ `tmux kill-ses -t mysession` -$ `tmux kill-session -t mysession` +* Move the current pane left +`<prefix> {` -* Kill/delete all sessions but the current -$ `tmux kill-session -a` +* Move the current pane right +`<prefix> }` -* Kill/delete all sessions but mysession -$ `tmux kill-session -a -t mysession` +* Switch to another pane depending on it's direction +`<prefix> <Up>` +`<prefix> <Down>` +`<prefix> <Right>` +`<prefix> <Left>` -* Rename session -`<prefix>$` +* Toggle synchronize-panes(send command to all panes) +`:setw synchronize-panes` -* Detach from session -`<prefix>d` +* Switch to next pane +`<prefix> o` -* Detach others on the session (Maximize window by detaching other clients) -`<prefix>:attach -d` +* Show pane numbers +`<prefix> q` -* Show all sessions -$ `tmux ls` -$ `tmux list-sessions` -`<prefix>s` +* Switch/select pane by number +`<prefix> q 0 ... 9` -* 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` +* Resize current pane height +`<prefix> Ctrl + <Up>` +`<prefix> Ctrl + <Down>` -* Move to previous session -`<prefix>(` +* Resize current pane width +`<prefix> Ctrl + <Left>` +`<prefix> Ctrl + <Right>` -* Move to next session -`<prefix>)` +* move current pane up or anti-clockwise +`:swap-pane -U` -#### WINDOWS +* move current pane down or clockwise +`:swap-pane -D` -* Start a new session with the name mysession and window mywindow -$ tmux new -s mysession -n mywindow +* move current pane to the left +`<prefix> {` +`:swap-pane -L` -* Create window -<prefix> c +* move current pane to the right +`<prefix> }` +`:swap-pane -R` -* Rename current window -<prefix> , +* show pane numbers (type number to move cursor) +`<prefix> q` -* Close current window -<prefix> & +* toggle pane arrangements/layouts +`<prefix> <Space>` -* Previous window -<prefix> p -* Next window -<prefix> n +* Toggle pane zoom +`<prefix> z` -* Switch/select window by number -<prefix> 0 ... 9 +* Convert pane into a window +`<prefix> !` -* Reorder window, swap window number 2(src) and 1(dst) -:swap-window -s 2 -t 1 +* Close current pane +`<prefix> x` +or just type +$ `exit` -* Move current window to the left by one position -:swap-window -t -1 - - - -* PANES - -* Toggle last active pane -<prefix> ; +- - - -* Split pane horizontally -<prefix> % +#### WINDOWS +* Start a new session with the name ***mysession*** and window ***mywindow*** +$ `tmux new -s mysession -n mywindow` -* Split pane vertically -<prefix> " +* Create window +`<prefix> c` -* Move the current pane left -<prefix> { +* Rename current window +`<prefix> ,` -* Move the current pane right -<prefix> } +* Previous window +`<prefix> p` -* Switch to pane to the direction -<prefix> <Up> -<prefix> <Down> -<prefix> <Right> -<prefix> <Left> +* Next window +`<prefix> n` -* Toggle synchronize-panes(send command to all panes) -:setw synchronize-panes +* rotate window +`<prefix> Ctrl-o` -* Toggle between pane layouts -<prefix> Spacebar +* Move cursor to next window +`<prefix> o` -* Switch to next pane -<prefix> o +* Switch/select window by number +`<prefix> 0 ... 9` -* Show pane numbers -<prefix> q +* Reorder window, swap window number 2(src) and 1(dst) +`:swap-window -s 2 -t 1` -* Switch/select pane by number -<prefix> q 0 ... 9 +* Move current window to the left by one position +`:swap-window -t -1` -* Toggle pane zoom -<prefix> z +* Close Window +`<prefix> &` +`:kill-window` +- - - -* Convert pane into a window -<prefix> ! +#### SESSIONS +* Start a new session +$ `tmux` +$ `tmux new` +$ `tmux new-session` +`<prefix> :new` -* Resize current pane height(holding second key is optional) -<prefix> + <Up> -<prefix> Ctrl + <Up> -<prefix> + <Down> -<prefix> Ctrl + <Down> +* Start a new session with the name ***mysession*** +$ `tmux new -s mysession` +`<prefix> :new -s mysession` -* Resize current pane width(holding second key is optional) -<prefix> + <Up> -<prefix> Ctrl + <Up> -<prefix> + <Down> -<prefix> Ctrl + <Down> +* Kill/delete session ***mysession*** +$ `tmux kill-ses -t mysession` +$ `tmux kill-session -t mysession` -* Close current pane -<prefix> x +* 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 +`<prefix> $` -* COPY MODE +* Detach from session +`<prefix> d` -* Use vi keys in buffer -:setw -g mode-keys vi +* Detach others on the session (Maximize window by detaching other clients) +`:attach -d` -* Enter copy mode -<prefix> [ +* Show all sessions +$ `tmux ls` +$ `tmux list-sessions` +`<prefix> s` -* Enter copy mode and scroll one page up -<prefix> PgUp +* Attach to last session +$ `tmux a` +$ `tmux at` +$ `tmux attach` +$ `tmux attach-session` -* Quit mode -<q> +* 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` -* Go to top line -<g> +* Move to previous session +`<prefix> (` -* Go to bottom line -<G> +* Move to next session +`<prefix> )` +- - - -* Scroll up -<Up> +#### Copy Mode +* Use vi keys +`:setw -g mode-keys vi` +or put this into tmux.conf: +```bash +set-window-option -g mode-keys vi +``` -* Scroll down -<Down> +* Enter copy mode +`<prefix> [` -* Move cursor left -<h> +* Enter copy mode and scroll one page up +`<prefix> <PgUp>` -* Move cursor down -<j> +* Quit mode +`<q>` -* Move cursor up -<k> +* Go to top line +`<g>` -* Move cursor right -<l> +* Go to bottom line +`<G>` -* Move cursor forward one word at a time -<w> +* Scroll up +`<Up>` -* Move cursor backward one word at a time -<b> +* Scroll down +`<Down>` -* Search forward -</> +* Move cursor left +`<h>` -* Search backward -<?> +* Move cursor down +`<j>` -* Next keyword occurance -<n> +* Move cursor up +`<k>` -* Previous keyword occurance -<N> +* Move cursor right +`<l>` -* Start selection -<Spacebar> +* Move cursor forward one word at a time +`<w>` -* Clear selection -<Esc> +* Move cursor backward one word at a time +`<b>` -* Copy selection -<Enter> +* Search forward +`</>` -* Paste contents of buffer_0 -<prefix> ] +* Search backward +`<?>` -* Display buffer_0 contents -:show-buffer +* Next keyword occurance +`<n>` -* Copy entire visible contents of pane to a buffer -:capture-pane +* Previous keyword occurance +`<N>` -* Show all buffers -:list-buffers +* Start selection +`<Space>` -* Show all buffers and paste selected -:choose-buffer +* Clear selection +`<Esc>` -* Save buffer contents to buf.txt -:save-buffer buf.txt +* Copy selection +`<Enter>` -* Delete buffer_1 -:delete-buffer -b 1 +* Paste contents of buffer_0 +`<prefix> ]` +* Display buffer_0 contents +`:show-buffer` +* Copy entire visible contents of pane to a buffer +`:capture-pane` -* MISC +* Show all buffers +`:list-buffers` -* Enter command mode -<prefix> : +* Show all buffers and paste selected +`:choose-buffer` -* Set OPTION for all sessions -:set -g OPTION +* Save buffer contents to buf.txt +`:save-buffer buf.txt` -* Set OPTION for all windows -:setw -g OPTION +* Delete buffer_1 +`:delete-buffer -b 1` +- - - -* Enable mouse mode -:set mouse on +#### MISC +* Enter command mode +`<prefix> :` +* Set OPTION for all sessions +`:set -g OPTION` +* Set OPTION for all windows +`:setw -g OPTION` -* HELP +* Enable mouse mode +`:set mouse on` +- - - -* List key bindings(shortcuts) -$ tmux list-keys -:list-keys -<prefix> ? +#### HELP +* List key bindings(shortcuts) +$ `tmux list-keys` +`:list-keys` +`<prefix> ?` -* Show every session, window, pane, etc... -$ tmux info +* Show every session, window, pane, etc... +$ `tmux info` +- - - |