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 tmux offers two key binding modes for copy mode: vi (Vim-like) and emacs. Each provides different navigation styles and key combinations based on their respective editors. 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
h, j, k, l
- Move cursor left, down, up, rightv
- Start selection (visual mode)y
- Yank (copy) selected text0
- Start of line, $
- End of line/
- Search forward, ?
- Search backwardn
- Next search match, N
- Previous matchCtrl+b
- Move cursor leftCtrl+f
- Move cursor rightCtrl+p
- Move cursor upCtrl+n
- Move cursor downCtrl+Space
- Set mark (start selection)Alt+w
- Copy selected textCtrl+a
- Start of line, Ctrl+e
- End of lineCtrl+s
- Search forward, Ctrl+r
- Search backwardTo 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'