Here's an exhaustive list of tmux commands and their arguments, with examples and use-cases.
Tmux Commands and Arguments¶
List Tmux Commands and Arguments, w/ Examles and Use-Cases¶
- attach-session
- -t: Target session
- -d: Detach other clients
Example: tmux attach-session -t mySession -d
Use Case: Attach to mySession and detach other clients connected to it.
- bind-key
- -T: Key table
- -n: No prefix key required
Example:
tmux bind-key -T root F1 new-session
Use Case:
Bind F1 to create a new session without needing a prefix key.
- break-pane
- -d: Leave pane in detached state
- -n: New window name
Example: tmux break-pane -d -n myWindow
Use Case: Break the current pane into a new window named myWindow and leave it detached.
- capture-pane
- -S: Start line
- -E: End line
Example:
tmux capture-pane -S -10 -E -1
Use Case:
Capture the last 10 lines of the current pane.
- choose-buffer Example: tmux choose-buffer
Use Case: Open a menu to choose a buffer to paste.
- choose-client Example: tmux choose-client
Use Case: Open a menu to choose a client to interact with.
- choose-session Example: tmux choose-session
Use Case: Open a menu to choose a session to attach to.
- choose-tree Example: tmux choose-tree
Use Case: Open a visual tree of sessions, windows, and panes to navigate through.
- choose-window Example: tmux choose-window
Use Case: Open a menu to choose a window to switch to.
- clear-history Example: tmux clear-history
Use Case: Clear the history of the current pane.
- clock-mode Example: tmux clock-mode
Use Case: Display a clock in the current pane.
- command-prompt Example: tmux command-prompt
Use Case: Open a command prompt within tmux.
- confirm-before
- -p: Prompt message
Example: tmux confirm-before -p "Are you sure?" "kill-server"
Use Case: Ask for confirmation before killing the tmux server.
- copy-mode
- -u: Scroll one page up
Example: tmux copy-mode -u
Use Case: Enter copy mode and scroll one page up.
- copy-pipe
- command: Shell command to pipe to
Example: tmux copy-pipe "pbcopy"
Use Case: Copy the selection and pipe it to pbcopy.
- delete-buffer
- -b: Buffer index
Example:
tmux delete-buffer -b 0
Use Case:
Delete the buffer at index 0.
- detach-client
- -s: Target session
- -a: All but current client
Example: tmux detach-client -s mySession
Use Case: Detach from the session named mySession.
- display-message
- -c: Target client
- -p: Print message to stdout
Example: tmux display-message -p "Current window: #{window_name}"
Use Case: Display the name of the current window and print it to stdout.
- display-panes Example: tmux display-panes
Use Case: Show pane numbers for easy selection.
- find-window
- -N: Search window names
- -C: Search window contents
Example: tmux find-window -N "myWindow"
Use Case: Find and switch to a window named myWindow.
- has-session
- -t: Target session
Example: tmux has-session -t mySession
Use Case: Check if a session named mySession exists.
- if-shell
- shell-command: Shell command to execute
- tmux-command: Tmux command to run if shell-command succeeds
Example: tmux if-shell "test -f ~/myfile" "display-message 'File exists'"
Use Case: Display a message if myfile exists in the home directory.
- join-pane
- -h: Join horizontally
- -v: Join vertically
Example: tmux join-pane -h
Use Case: Join the current pane horizontally with another pane.
- kill-pane
- -t: Target pane
Example:
tmux kill-pane -t 1
Use Case:
Kill the pane with the ID 1.
- kill-server Example: tmux kill-server
Use Case: Kill the tmux server, ending all sessions.
- kill-session
- -t: Target session
Example: tmux kill-session -t mySession
Use Case: Kill a session named mySession.
- kill-window
- -t: Target window
Example: tmux kill-window -t myWindow
Use Case: Kill a window named myWindow.
- last-pane Example: tmux last-pane
Use Case: Switch to the last pane.
- last-window Example: tmux last-window
Use Case: Switch to the last window.
- link-window
- -s: Source window
- -t: Target window
Example: tmux link-window -s srcWindow -t tgtWindow
Use Case: Link srcWindow to tgtWindow, effectively mirroring it.
- list-buffers Example: tmux list-buffers
Use Case: List all paste buffers.
- list-clients Example: tmux list-clients
Use Case: List all connected clients.
- list-commands Example: tmux list-commands
Use Case: List all available tmux commands.
- list-keys Example: tmux list-keys
Use Case: List all key bindings.
- list-panes Example: tmux list-panes
Use Case: List all panes in the current window.
- list-sessions
- -F: Format
Example: tmux list-sessions -F "#{session_name}"
Use Case: List all session names.
- list-windows Example: tmux list-windows
Use Case: List all windows in the current session.
- load-buffer
- -b: Buffer name
- path: File path
Example: tmux load-buffer -b myBuffer ~/myfile
Use Case: Load the contents of myfile into a buffer named myBuffer.
- lock-client
- -t: Target client
Example: tmux lock-client -t myClient
Use Case: Lock the client named myClient.
- lock-server Example: tmux lock-server
Use Case: Lock the tmux server, requiring a password to unlock.
- lock-session
- -t: Target session
Example: tmux lock-session -t mySession
Use Case: Lock the session named mySession.
- move-pane
- -t: Target window
Example: tmux move-pane -t myWindow
Use Case: Move the current pane to a window named myWindow.
- move-window
- -t: Target session
- -s: Source window
Example: tmux move-window -s srcWindow -t tgtSession
Use Case: Move srcWindow to a session named tgtSession.
- new-session
- -s: Session name
- -n: Window name
- -c: Start directory
- -d: Detached session
Example: tmux new-session -s mySession -n myWindow -c ~/myDir -d
Use Case: Create a new detached session named mySession, with a window named myWindow, starting in the directory ~/myDir.
- new-window
- -n: Window name
- -c: Start directory
- -d: Detached window
Example: tmux new-window -n myNewWindow -c ~/anotherDir -d
Use Case: Create a new detached window named myNewWindow, starting in the directory ~/anotherDir.
- next-layout Example: tmux next-layout
Use Case: Cycle through available pane layouts.
- next-window Example: tmux next-window
Use Case: Switch to the next window.
- paste-buffer
- -b: Buffer index
- -t: Target pane
Example: tmux paste-buffer -b 0 -t 1
Use Case: Paste the buffer at index 0 to the pane with the ID 1.
- pipe-pane
- -o: Only pipe new output
- command: Shell command to pipe to
Example: tmux pipe-pane -o "cat >>~/mylog"
Use Case: Pipe new output from the current pane to ~/mylog.
- previous-layout Example: tmux previous-layout
Use Case: Switch to the previous pane layout.
- previous-window Example: tmux previous-window
Use Case: Switch to the previous window.
- refresh-client
- -S: Save layout
Example: tmux refresh-client -S
Use Case: Refresh the client and save the current layout.
- rename-session
- new-name: New session name
Example: tmux rename-session newSession
Use Case: Rename the current session to newSession.
- rename-window
- new-name: New window name
Example: tmux rename-window newWindow
Use Case: Rename the current window to newWindow.
- resize-pane
- -U: Resize up
- -D: Resize down
- -L: Resize left
- -R: Resize right
Example: tmux resize-pane -U 10
Use Case: Resize the current pane 10 cells up.
- resize-window
- -U: Resize up
- -D: Resize down
- -L: Resize left
- -R: Resize right
Example: tmux resize-window -U 10
Use Case: Resize the current window 10 cells up.
- respawn-pane
- -k: Kill existing pane
- command: Command to execute
Example: tmux respawn-pane -k "top"
Use Case: Kill the current pane and replace it with a new pane running top.
- respawn-window
- -k: Kill existing window
- command: Command to execute
Example: tmux respawn-window -k "htop"
Use Case: Kill the current window and replace it with a new window running htop.
- rotate-window
- -D: Rotate down
- -U: Rotate up
Example: tmux rotate-window -U
Use Case: Rotate the panes in the current window up.
- run-shell
- command: Shell command to execute
Example: tmux run-shell "echo Hello"
Use Case: Run a shell command that echoes "Hello".
- save-buffer
- -b: Buffer index
- path: File path
Example: tmux save-buffer -b 0 ~/myfile
Use Case: Save the buffer at index 0 to myfile.
- select-layout
- layout-name: Name of the layout
Example: tmux select-layout even-horizontal
Use Case: Switch to an even horizontal layout.
- select-pane
- -U: Up
- -D: Down
- -L: Left
- -R: Right
Example: tmux select-pane -U
Use Case: Move to the pane above the current one.
- select-window
- -t: Target window
Example: tmux select-window -t myWindow
Use Case: Switch to a window named myWindow.
- send-keys
- -t: Target pane
- -l: Literal string
- -R: Clear pane's input buffer
Example: tmux send-keys -t 1 "ls -la" C-m
Use Case: Send the command ls -la followed by Enter (C-m) to pane with the ID 1.
- send-prefix Example: tmux send-prefix
Use Case: Send the prefix key to the current pane.
- set-buffer
- -b: Buffer index
- data: Data to set
Example: tmux set-buffer -b 0 "Hello"
Use Case: Set the buffer at index 0 to contain the string "Hello".
- set-environment
- -g: Global variable
- -u: Unset variable
Example: tmux set-environment -g MY_VAR "value"
Use Case: Set a global environment variable MY_VAR to "value".
- set-hook
- hook-name: Name of the hook
- command: Command to run
Example: tmux set-hook after-new-window "display-message 'New window created'"
Use Case: Display a message when a new window is created.
- set-option
- -g: Global option
- -w: Window option
- -s: Server option
Example: tmux set-option -g status off
Use Case: Turn off the status bar globally.
- set-window-option
- option: Window option
- value: Value to set
Example: tmux set-window-option automatic-rename on
Use Case: Automatically rename windows based on the running application.
- show-buffer
- -b: Buffer index
Example: tmux show-buffer -b 0
Use Case: Show the contents of the buffer at index 0.
- show-environment
- -g: Show global variables
Example: tmux show-environment -g
Use Case: Show all global environment variables.
- show-hooks Example: tmux show-hooks
Use Case: Show all configured hooks.
- show-messages Example: tmux show-messages
Use Case: Show client messages.
- show-options
- -g: Global options
- -w: Window options
- -s: Server options
Example: tmux show-options -g
Use Case: Show all global options.
- show-window-options Example: tmux show-window-options
Use Case: Show all window options.
- source-file
- file: File to source
Example: tmux source-file ~/.tmux.conf
Use Case: Reload the tmux configuration file.
- split-window
- -h: Horizontal split
- -v: Vertical split
- -c: Start directory
Example: tmux split-window -h -c ~/splitDir
Use Case: Split the current pane horizontally and start in the directory ~/splitDir.
- start-server Example: tmux start-server
Use Case: Start the tmux server.
- suspend-client
- -t: Target client
Example: tmux suspend-client -t myClient
Use Case: Suspend the client named myClient.
- swap-pane
- -s: Source pane
- -t: Target pane
Example: tmux swap-pane -s 1 -t 2
Use Case: Swap pane 1 with pane 2.
- swap-window
- -s: Source window
- -t: Target window
Example: tmux swap-window -s 1 -t 2
Use Case: Swap window 1 with window 2.
- switch-client
- -n: Next session
- -p: Previous session
- -t: Target session
Example: tmux switch-client -t anotherSession
Use Case: Switch to another session named anotherSession.
- unbind-key
- -T: Key table
Example: tmux unbind-key -T root F1
Use Case: Unbind F1 from the root key table.
- unlink-window
- -k: Kill window if becomes detached
Example: tmux unlink-window -k
Use Case: Unlink the current window and kill it if it becomes detached.
- wait-for
- channel: Channel to wait for
Example: tmux wait-for myChannel
Use Case: Wait for a signal on myChannel.
Tips for Increasing Productivity with Tmux¶
-
Session Management Example: Create a script that automatically sets up a development environment with multiple windows and panes.
-
Pane Layouts Example: Use tmux select-layout to quickly switch between different pane layouts like even-horizontal, even-vertical, main-horizontal, and main-vertical.
-
Quick Commands Example: Bind Ctrl+b, Ctrl+e to open your preferred text editor.
-
Clipboard Integration Example: Use tmux-yank plugin for seamless clipboard integration between tmux and your system.
-
Status Bar Customization Example: Show the current Git branch in the status bar.