To enter copy mode in tmux, press Ctrl+b
followed by [
(left square bracket). This lets you scroll, search, and copy text. Press q
to exit copy mode.
Copy mode in tmux allows you to navigate through terminal history, search for text, and copy content to the clipboard. It's essential for reviewing output that has scrolled off the screen and for copying text between panes or windows.
Ctrl+b [
- Enter copy modeq
- Exit copy modeArrow keys
- Navigate in copy modePage Up/Down
- Scroll page up/downHome/End
- Go to start/end of lineCtrl+b [
to enter copy modeSpace
to start selection (or v
in vi mode)Enter
to copy selection to tmux bufferCtrl+b ]
to paste the copied text/
- Search forward?
- Search backwardn
- Next search matchN
- Previous search match tmux offers two key binding modes for copy mode: vi (Vim-like) and emacs. Set your preferred mode in ~/.tmux.conf
:
# For vi mode set-window-option -g mode-keys vi # For emacs mode set-window-option -g mode-keys emacs
To copy text directly to your system clipboard, you'll need additional configuration:
# For macOS set-option -g default-command "reattach-to-user-namespace -l $SHELL" bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy' # For Linux with xclip bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel 'xclip -selection clipboard'