From ed2be86b970350be0b6aa8f18b63a313f3c76983 Mon Sep 17 00:00:00 2001 From: johannst Date: Thu, 19 Mar 2020 00:25:40 +0100 Subject: added tmux --- src/SUMMARY.md | 1 + src/tmux.md | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 src/tmux.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index fe0b341..73562df 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -2,6 +2,7 @@ - [ld.so](./ld.so.md) - [git](./git.md) +- [tmux](./tmux.md) - [awk](./awk.md) - [gdb](./gdb.md) - [radare2](./radare2.md) diff --git a/src/tmux.md b/src/tmux.md new file mode 100644 index 0000000..04b1111 --- /dev/null +++ b/src/tmux.md @@ -0,0 +1,110 @@ +# tmux(1) + +Terminology: +- `session` is a collection of pseudo terminals which can have multiple + `windows` +- `window` uses the entire screen and can be split into rectangular `panes` +- `pane` is a single pseudo terminal instance + +# Tmux cli +```markdown +# Session +tmux creates new session +tmux ls list running sessions +tmux kill-session -t kill running session +tmux attach -t [-d] attach to session , detach other clients [-d] +tmux detach -s detach all clients from session + +# Environment +tmux showenv -g show global tmux environment variables +tmux setenv -g set variable in global tmux env + +# Misc +tmux source-file source config +tmux lscm list available tmux commnds +tmux show -g show global tmux options +tmux display display message in tmux status line +``` +## Scripting +```markdown +# Session +tmux list-sessions -F '#S' list running sessions, only IDs + +# Window +tmux list-windows -F '#I' -t list window IDs for session +tmux selectw -t : select window in session + +# Pane +tmux list-panes -F '#P' -t : list pane IDs for window in session +tmux selectp -t :.

select pane

in window in session + +# Run commands +tmux send -t :.

"ls" C-m send cmds/keys to pane +tmux run -t

run shell command in background and report output on pane -t

+``` + +For example cycle through all panes in all windows in all sessions: +```bash +# bash +for s in $(tmux list-sessions -F '#S'); do + for w in $(tmux list-windows -F '#I' -t $s); do + for p in $(tmux list-panes -F '#P' -t $s:$w); do + echo $s:$w.$p + done + done +done +``` + +# Bindings + +```markdown +prefix d detach from current session +prefix c create new window +prefix w open window list +prefix $ rename session +prefix , rename window +prefix . move current window +``` + +Following bindings are specific to my [`tmux.conf`](https://github.com/johannst/dotfiles/blob/master/tmux.conf): +```markdown +C-s prefix + +# Panes +prefix s horizontal split +prefix v vertical split +prefix f toggle maximize/minimize current pane + +# Movement +prefix Tab toggle between window + +prefix h move to pane left +prefix j move to pane down +prefix k move to pane up +prefix l move to pane right + +# Resize +prefix C-h resize pane left +prefix C-j resize pane down +prefix C-k resize pane up +prefix C-l resize pane right + +# Copy/Paste +prefix C-v enter copy mode +prefix C-p paste yanked text +prefix C-b open copy-buffer list + +# In Copy Mode +v enable visual mode +y yank selected text +``` + +# Command mode + +To enter command mode `prefix :`. + +Some useful commands are: +```markdown +setw synchronize-panes on/off enables/disables synchronized input to all panes +list-keys -t vi-copy list keymaps for vi-copy mode +``` -- cgit v1.2.3