set -g default-terminal "tmux-256color" set -g mouse on set -g mode-keys vi # Better clipboard on mousedrag (https://unix.stackexchange.com/a/349020) # Disable xterm escape sequences for setting clipboard set -s set-clipboard off # Copy selection into primary selection (without aborting) bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-no-clear "xclip -se p" # https://github.com/neovim/neovim/wiki/FAQ#cursor-shape-doesnt-change-in-tmux set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q' # Do not exit automatically the copy-mode when reaching the bottom. This was # especially annoying/dangerous when holding C-d down to scroll to the bottom. # (This is practically the default binding except for the `-e` flag for # `copy-mode`) bind -n WheelUpPane \ if -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" { send -M } { copy-mode -u } bind -T copy-mode-vi WheelUpPane selectp \; send -XN5 scroll-up bind -T copy-mode-vi WheelDownPane selectp \; send -XN5 scroll-down # Set C-a as new prefix unbind C-b set -g prefix C-a bind C-a send-prefix # Split panes with > and < unbind % bind < splitw -v -c "#{pane_current_path}" unbind '"' bind > splitw -h -c "#{pane_current_path}" # Create new window in current path bind c neww -c "#{pane_current_path}" # Resource config bind R source-file "$XDG_CONFIG_HOME/tmux/tmux.conf" \; \ display "Sourced $XDG_CONFIG_HOME/tmux/tmux.conf" # Fullscreen pane (toggle) bind F resizep -Z # Automatically renumber windows when closing one set -g renumber-windows on # Enter copy-mode and scroll one page up directly with PageUp without the need # of the prefix. (Exists already per default with prefix) bind -n PPage copy-mode -u # Repeatable window-navigation bindings bind -r n next bind -r C-n next bind -r p prev bind -r C-p prev # Vim-bindings # Enter copy-mode with Escape bind Escape copy-mode # Start selection (e.g. visual mode) with `v` unbind -T copy-mode-vi v bind -T copy-mode-vi v send -X begin-selection # Yank into system clipboard bind -T copy-mode-vi y send -X copy-pipe "xclip -selection clipboard" # Clear selection or cancel copy-mode when nothing is selected bind -T copy-mode-vi Escape \ if -F "#{selection_present}" { send -X clear-selection } { send -X cancel } # Navigate panes with -[hjkl] # NOTE: C-[hjkl] (w/o prefix) moves through vim splits and tmux panes # See vim-tmux-navigator unbind l bind h selectp -L bind j selectp -D bind k selectp -U bind l selectp -R # Resize panes with Alt-Shift-[hjkl] bind -n M-H resizep -L bind -n M-J resizep -D bind -n M-K resizep -U bind -n M-L resizep -R # Allow C-h to still be passed (when programs expect it as backspace, e.g. UEFI # shell) bind -r -T selfinsert C-h send C-h bind C-v switchc -T selfinsert # Resize panes with Alt-Shift- bind -n M-S-Left resizep -L bind -n M-S-Up resizep -D bind -n M-S-Down resizep -U bind -n M-S-Right resizep -R # Change installation location of plugins setenv -g TMUX_PLUGIN_MANAGER_PATH "$XDG_CONFIG_HOME/tmux/plugins/" ## Plugins set -g @plugin 'tmux-plugins/tmux-continuum' set -g @plugin 'tmux-plugins/tmux-prefix-highlight' set -g @plugin 'tmux-plugins/tmux-resurrect' set -g @plugin 'tmux-plugins/tmux-sensible' set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'vim-tmux-navigator' # Capture pane content set -g @resurrect-capture-pane-contents 'on' # Change keybindings set -g @resurrect-save 'C-s' set -g @resurrect-restore 'C-r' # Save session every 5 min set -g @continuum-save-interval '5' # Last saved environment is automatically restored when tmux is started. set -g @continuum-restore 'on' # Restore {,neo}vim sessions with the help of vim-obsession # https://github.com/tpope/vim-obsession set -g @resurrect-strategy-vim 'session' set -g @resurrect-strategy-nvim 'session' # Save sessions before detaching unbind d bind d { run "$XDG_CONFIG_HOME/tmux/plugins/tmux-resurrect/scripts/save.sh"; detach } ## Theming. Inspired by: ## https://github.com/Who23/dots/blob/21976e76644d8d9261ebdcf61733d2181a1612eb/tmux.conf set -g status-style bg=default,fg=white set -g message-command-style bg=default,fg=brightyellow set -g message-style bg=brightyellow,fg=black set -g mode-style bg=brightyellow,fg=black set -g pane-border-style bg=default,fg=brightblack set -g pane-active-border-style bg=default,fg=brightyellow # Display prefix when pressed set -g @prefix_highlight_fg 'black' set -g @prefix_highlight_bg 'brightyellow' set -g @prefix_highlight_output_prefix ' ' set -g @prefix_highlight_output_suffix ' ' set -g status-right "#{prefix_highlight}" set -g status-left "#{prefix_highlight}" set -g status-justify centre set -g window-status-current-format "#[fg=brightyellow bold]#I #W" set -g window-status-format "#[fg=brightblack]#I #W" # Initialize TMUX plugin manager. Keep this line at the very bottom. run -b "$XDG_CONFIG_HOME/tmux/plugins/tpm/tpm"