205 lines
6.9 KiB
Bash
205 lines
6.9 KiB
Bash
set -g default-terminal "tmux-256color"
|
|
set -g mouse on
|
|
set -g mode-keys vi
|
|
set -g extended-keys always
|
|
|
|
set -g prompt-history-limit 999999
|
|
set -g history-file "$XDG_DATA_HOME/tmux/tmux_history"
|
|
run-shell 'mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/tmux"'
|
|
|
|
# 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'
|
|
|
|
# Scroll up 5 lines when entering copy-mode through the mouse wheel, send 5x`up`
|
|
# when the current pane is in alternate mode and discard the `-e` flag passed to
|
|
# copy-mode from the default binding (See below)
|
|
# TODO: Do not modify selection when scolling with the wheel
|
|
bind -n WheelUpPane \
|
|
if -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" {
|
|
send -M
|
|
} {
|
|
if -F "#{alternate_on}" {
|
|
send -N5 up
|
|
} {
|
|
copy-mode; send -XN5 scroll-up
|
|
}
|
|
}
|
|
# Scroll without selecting the pane
|
|
bind -T copy-mode-vi WheelUpPane send -XN5 scroll-up
|
|
# Exit copy-mode when at the bottom. This practically mimics `copy-mode -e` but
|
|
# only scrolling with the wheel (`-e` annoys me when scrolling down with `C-d`).
|
|
bind -T copy-mode-vi WheelDownPane \
|
|
if -F "#{==:0,#{scroll_position}}" {send -X cancel} {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
|
|
# Number windows with 1-based indices
|
|
set -g base-index 1
|
|
|
|
# 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 <prefix>-[hjkl]
|
|
# NOTE: C-[hjkl] (w/o prefix) moves through vim splits and tmux panes
|
|
# See vim-tmux-navigator
|
|
unbind l
|
|
bind -r h selectp -L
|
|
bind -r j selectp -D
|
|
bind -r k selectp -U
|
|
bind -r 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
|
|
|
|
# Create a key-table which self-inserts all keys that are bound in the root key
|
|
# table. (C-h for example is sometimes needed as backspace sequence)
|
|
#
|
|
# tmux_selfinsert.sh:
|
|
#
|
|
# tmux list-keys -T root | awk '{print $4}' | while read key; do
|
|
# tmux bind -r -T selfinsert "$key" send
|
|
# done
|
|
|
|
run-shell -b "$XDG_CONFIG_HOME/tmux/tmux_selfinsert.sh"
|
|
bind C-v switchc -T selfinsert
|
|
|
|
# Synchronize the panes in the current window with `<prefix>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 -b "$XDG_CONFIG_HOME/tmux/plugins/tmux-resurrect/scripts/save.sh";
|
|
detach
|
|
}
|
|
|
|
## Theming
|
|
set -g @accent_color 'brightyellow'
|
|
set -g @ui_color 'brightblack'
|
|
set -g @sync_color 'brightred'
|
|
set -g @text_fg 'black'
|
|
|
|
set -g status-style bg=default,fg=white
|
|
set -g message-command-style 'bg=default,fg=#{@accent_color}'
|
|
set -g message-style 'bg=#{@accent_color},fg=#{@text_fg}'
|
|
set -g mode-style 'bg=#{@accent_color},fg=#{@text_fg}'
|
|
|
|
# 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=#{@ui_color}'
|
|
set -g pane-active-border-style 'bg=default,fg=#{@accent_color}'
|
|
|
|
set -g @prefix_highlight_show_copy_mode 'on'
|
|
set -g @prefix_highlight_show_sync_mode 'on'
|
|
set -g @prefix_highlight_copy_mode_attr 'fg=#{@text_fg},bg=#{@accent_color}'
|
|
set -g @prefix_highlight_sync_mode_attr 'fg=#{@text_fg},bg=#{@sync_color}'
|
|
} {
|
|
# 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=#{@sync_color},fg=#{@ui_color}}"
|
|
set -g pane-active-border-style "#{?pane_in_mode,bg=#{@accent_color}#,fg=#{@ui_color},#{?synchronize-panes,fg=#{@sync_color},fg=#{@accent_color}}}"
|
|
}
|
|
|
|
# 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 '#{@accent_color}'
|
|
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=#{@accent_color} bold]#I #W"
|
|
set -g window-status-format "#[fg=#{@ui_color}]#I #W"
|
|
|
|
# Initialize TMUX plugin manager. Keep this line at the very bottom.
|
|
run -b "$XDG_CONFIG_HOME/tmux/plugins/tpm/tpm"
|