Skip to content

Instantly share code, notes, and snippets.

@marioaquino
Last active September 25, 2020 16:31
Show Gist options
  • Save marioaquino/5a7e58ce4485ef7eaace to your computer and use it in GitHub Desktop.
Save marioaquino/5a7e58ce4485ef7eaace to your computer and use it in GitHub Desktop.
This tmux config includes mouse click for window selection, wheel scrolling, custom leader key, and OS-level copy/paste support
# Make Ctrl+\ the tmux leader combination
unbind C-b
set -g prefix "C-\\"
bind "C-\\" send-prefix
setw -g xterm-keys on
set -g default-terminal "screen-256color"
set -sg escape-time 0
set -g base-index 1
# Scroll your way into copy mode (scrollback buffer)
# and select text for copying with the mouse
set-option -g mouse on
# Copy/paste support
set-option -g default-command "reattach-to-user-namespace -l bash"
bind y run "tmux show-buffer | reattach-to-user-namespace pbcopy"
bind p run "reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer"
# To copy something from the terminal session (in tmux) into the OS paste buffer, do the following:
# Ctrl+\ [ (Enter copy mode in tmux)
# (move the cursor to where you want to start copying)
# Ctrl+Space (enter region highlight mode - like emacs)
# (highlight the things you want to copy)
# Alt+w (copy the highlighted text to tmux copy buffer)
# Ctrl+\ y (copy the tmux copy buffer into the OS copy buffer)
# Cmd+v (paste what you've copied into wherever you want in the OS)
#
#
# To copy something from the terminal session (in tmux) into some other place
# in the terminal (instead of moving into the OS paste buffer)
# Ctrl+\ [ (Enter copy mode in tmux)
# (move the cursor to where you want to start copying)
# Ctrl+Space (enter region highlight mode - like emacs)
# (highlight the things you want to copy)
# Alt+w (copy the highlighted text to tmux copy buffer)
# Ctrl+\ ] (paste the copied content into wherever the cursor is)
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment