Tmux Commands - ankit-jha/commands GitHub Wiki

Tmux Design

tmux.conf

set is the alias of set-option

set -g is used to set global options and -ga appends values to existing settings.

set -g mouse on # Mouse scrolling for tmux windows/panes

set -g history-limit 5000 # Set history limit

setw is the alias of set-window-option

tmux commands

Outside tmux session

tmux new # Create a new session

tmux new-session -s dev OR tmux new -s dev # Create a new session with name dev

tmux ls #List all sessions

tmux list-keys # List all key bindings

tmux -t dev select-window -t 1

tmux attach-session -t dev OR tmux a -t dev #Attached to an already existing tmux session named dev

tmux display-message -p '#S' #Show last visited session

tmux kill-session -t dev #Kill tmux dev session

tmux kill-server #Kill tmux server, along with all sessions

Inside tmux session

ctrl-a % # Split panes vertically

ctrl-a " #Split panes horizontally

ctrl-a x # Kill current pane

ctrl-a [arrow key] # Move to another pane

ctrl-a ; #Cycle just between previous and current pane

ctrl-a o #Cycle through panes

ctrl-a :resize-pane -D 2 #Resize panes down by 2 cells

ctrl-a :resize-pane -U 2 #Resize panes up by 2 cells

ctrl-a :resize-pane -L 2 #Resize panes left by 2 cells

ctrl-a :resize-pane -R 2 #Resize panes right by 2 cells

ctrl-a :resize-pane -Z OR ctrl-a z #Toggles between zoomed (maximized window) and unzoomed (restored layout window)

ctrl-a :join-pane -s session1:2 -t session2:1 #This will move the 2nd window from session 1 as a pane to the 1st window in session2. ctrl-a :join-pane -s 2 -t 1 #This will move the 2nd window as a pane to the 1st window. Join Panes

ctrl-a+$ #Rename the current running session

ctrl-a+[+[arrow-key] # Copy Mode to scroll with arrow keys. Press q to quit scroll mode.

ctrl-a+[+ctrl-s # Copy Mode Search. Press Ctrl-s then type the string to search for and press Enter. n(Fwd)/Shift-n(Rev) to search for the same string again.

ctrl-a d or ctrl-a :detach #Detach from a session

ctrl-a d or ctrl+a :detach #Detach from a screen

ctrl-a ( #Go to previous session

ctrl-a ) #Go to next session

ctrl-a L #Go to last session

Windows

ctrl-a :new-window #Create a new window while being inside the session

ctrl-a :new-window -n dev #Create a new window named dev while being inside the session

ctrl-a+f #Find a window

ctrl-a+l #Switch to the last window

ctrl-a+2 #Switch to window number 2

ctrl-a+s #Show all sessions

ctrl+s #In copy mode allows to search

ctrl-a+w #Show all windows for the current session

ctrl-a+c #Create a new window for the current session

ctrl-a+, #Rename the current window

ctrl-a+movew -r #Renumber all windows

ctrl-a+& #Kill the current window (and all the panes in it)

ctrl-a+space #Sets the default layout

Panes

ctrl-a+ctrl+o #Moves the panes in the current window in clockwise direction. In case of 2 panes it switches them.

ctrl-a+ctrl+{ #Swaps pane

ctrl-a+; #Switches to last pane

ctrl-a+kill-pane -a -t 0 #Kill all(-a) panes except target(-t) pane 0

Help

ctrl-a+? #Show shortcuts

Linux Copy Paste Setup

https://tmuxcheatsheet.com/

Plugins

Tmux Plugins

ctrl-a+I #Install the plugins