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 # Repeatable window-movement bindings bind -r \{ swap-pane -U bind -r \} swap-pane -D # 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 mode similar to my i3 config bind -T resize h resizep -L \; switchc -T resize bind -T resize j resizep -D \; switchc -T resize bind -T resize k resizep -U \; switchc -T resize bind -T resize l resizep -R \; switchc -T resize bind -T resize 1 selectl even-horizontal \; switchc -T resize bind -T resize 2 selectl even-vertical \; switchc -T resize bind -T resize 3 selectl main-horizontal \; switchc -T resize bind -T resize 4 selectl main-vertical \; switchc -T resize bind -T resize 5 selectl tiled \; switchc -T resize bind r switchc -T resize # 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 # Synchronize the panes in the current window with `S` bind S set -w synchronize-panes # 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 # NOTE: `<` does string comparison with `strcmp()`. This means that the # condition will break from a double digit major version (e.g. `10.0`) on. if -F "#{<:#{version},3.2}" { # Use pure style default for tmux < 3.2 in combination with the # prefix_highlight plugin. set -g pane-border-style bg=default,fg=brightblack set -g pane-active-border-style bg=default,fg=brightyellow set -g @prefix_highlight_show_copy_mode 'on' set -g @prefix_highlight_show_sync_mode 'on' set -g @prefix_highlight_copy_mode_attr 'fg=black,bg=brightyellow' set -g @prefix_highlight_sync_mode_attr 'fg=black,bg=brightred' } { # From 3.2 on, we can use formats in styles, so that all indicators can be # done by the borders. set -g pane-border-style "#{?synchronize-panes,fg=brightred,fg=brightblack}" set -g pane-active-border-style "#{?pane_in_mode,bg=brightyellow#,fg=brightblack,#{?synchronize-panes,fg=brightred,fg=brightyellow}}" } # Display in the status bar when the prefix was pressed, copy-mode is active, or # `synchronize-panes` is turned on set -g @prefix_highlight_fg 'brightyellow' set -g @prefix_highlight_bg 'default' 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"