Linux: Configure tmux for better mouse support and copy/paste
If you are using tmux in a Ubuntu desktop terminal environment the following setup will help smooth out the “feel” of using tmux with multiple panes:
create a ~/.tmux.conf file:
nano ~/.tmux.conf
Add the following code into the file:
# Use vi keys in copy-mode
setw -g mode-keys vi
# Only redefine Enter and y inside copy-mode (not globally!)
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
# Mouse support (optional)
set -g mouse on
Reload your tmux session:
tmux source-file ~/.tmux.conf
Test:
Test
Try Ctrl-b " → should still split horizontally.
Try Ctrl-b % → should still split vertically.
Try copy workflow:
Ctrl-b [ → enter copy-mode
Move cursor, press Space, move, press Enter → text now in Ubuntu clipboard.
Remember:
Enter copy-mode: Ctrl-b [
Move cursor with arrows or hjkl.
Press Space to start selecting.
Move to the end of text.
Press Enter → now it’s in your Ubuntu clipboard.
Paste anywhere in Ubuntu with Ctrl+Shift+V (terminal) or Ctrl+V (GUI apps).