Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sane Tmux config which can be used with mouse and have nice copy/tiling/searching things turned on and added to right mouse button menu
# Open window/pane in the same PATH
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
# Reload config
bind R source-file ~/.tmux.conf \; display-message "Config reloaded..."
# Window tab menu
bind-key -T root MouseDown3Status display-menu -T "#[align=centre]#{window_index}:#{window_name}" -t = -x W -y S \
"Swap Left" l "swap-window -t:-1" \
"Swap Right" r "swap-window -t:+1" \
"#{?pane_marked_set,,-}Swap Marked" s swap-window \
"" \
Kill X kill-window \
Respawn R "respawn-window -k" \
"#{?pane_marked,Unmark,Mark}" m "select-pane -m" \
Rename n "command-prompt -I \"#W\" \"rename-window -- '%%'\"" \
"" \
"New After" w "new-window -a" \
"New At End" W new-window
# Window status left menu
bind-key -T root MouseDown3StatusLeft display-menu -T "#[align=centre]#{session_name}" -t = -x M -y S \
Next n "switch-client -n" \
Previous p "switch-client -p" \
"" \
Renumber N "move-window -r" \
Rename n "command-prompt -I \"#S\" \"rename-session -- '%%'\"" \
"" \
"New Session" s new-session \
"New Window" w "new-window -c \"#{pane_current_path}\"" \
# Window status right menu
bind-key -T root MouseDown3StatusRight display-menu -T "#[align=centre]#{client_name}" -t = -x M -y S \
Detach d detach-client \
"Detach & Kill" X "detach-client -P" \
"Detach Others" o "detach-client -a" \
"" \
"Save session" C-s "run-shell ~/.tmux/plugins/tmux-resurrect/scripts/" \
"Restore session" C-r "run-shell ~/.tmux/plugins/tmux-resurrect/scripts/" \
"Switch to" g "run-shell ~/.tmux/plugins/tmux-sessionist/scripts/" \
"" \
"Reload config" R "source-file ~/.tmux.conf \; display-message \"Config reloaded...\"" \
"Install plugin" I "run-shell ~/.tmux/plugins/tpm/bindings/install_plugins" \
"" \
Lock l lock-client \
# Pane menu
bind-key -T root MouseDown3Pane display-menu -T "#[align=centre]#{pane_index} (#{pane_id})" -t = -x M -y M \
"Search regexp" / "run-shell ~/.tmux/plugins/tmux-copycat/scripts/" \
"#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}" C-r "copy-mode -t=; send -Xt= search-backward \"#{q:mouse_word}\"" \
"#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}" C-y "send-keys -l -- \"#{q:mouse_word}\"" \
"#{?mouse_word,Copy #[underscore]#{=/9/...:mouse_word},}" c "set-buffer -- \"#{q:mouse_word}\"" \
"#{?mouse_line,Copy Line,}" l "set-buffer -- \"#{q:mouse_line}\"" \
"" \
"Toggle logging" P "run-shell ~/.tmux/plugins/tmux-logging/scripts/" \
"Screen capture" M-p "run-shell ~/.tmux/plugins/tmux-logging/scripts/" \
"Save history" M-P "run-shell ~/.tmux/plugins/tmux-logging/scripts/" \
"Clear pane history" M-c "run-shell ~/.tmux/plugins/tmux-logging/scripts/" \
"" \
"Horizontal Split" h "split-window -h -c \"#{pane_current_path}\"" \
"Vertical Split" v "split-window -v -c \"#{pane_current_path}\"" \
"" \
"Swap Up" u "swap-pane -U" \
"Swap Down" d "swap-pane -D" \
"#{?pane_marked_set,,-}Swap Marked" s swap-pane \
"" \
Kill X kill-pane \
Respawn R "respawn-pane -k" \
"#{?pane_marked,Unmark,Mark}" m "select-pane -m" \
"" \
"#{?window_zoomed_flag,Unzoom,Zoom}" z "resize-pane -Z" \
# Use ZSH so that default shell can be changed to tmux
set-option -g default-shell /usr/bin/zsh
# Initialize Tmux Plugin Manager
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# Copying (prefix + y: command, prefix + Y: PWD)
set -g set-clipboard external
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @yank_action 'copy-pipe'
set -g @yank_selection 'clipboard'
set -g @yank_selection_mouse 'clipboard'
# Searching (prefix + /, n, N), copying (prefix + y: command, prefix + Y: PWD)
set -g @plugin 'tmux-plugins/tmux-copycat'
# Logging (prefix + P: start, prefix + alt + p: dump pane, prefix + alt + P: full history to file, prefix + alt + c: clear)
set -g @plugin 'tmux-plugins/tmux-logging'
# Mouse support
set-option -g mouse on
set -g terminal-overrides 'screen*:smcup@:rmcup@'
set -g @scroll-in-moused-over-pane 'on'
set -g @emulate-scroll-for-no-mouse-alternate-buffer 'on'
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
# Session management (prefix + s, prefix + r)
set -g @plugin 'tmux-plugins/tmux-resurrect'
# (prefix + g: ask for name and switch to it, prefix + C: create new with a name, prefix + X: killcurrent without exiting tmux, prefix + S: go back to last session, prefix + t + "/%/@: join)
set -g @plugin 'tmux-plugins/tmux-sessionist'
# Sidebar (prefix + tab)
set -g @plugin 'tmux-plugins/tmux-sidebar'
run -b '~/.tmux/plugins/tpm/tpm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment