Files
dotfiles/.config/tmux/tmux.conf
Julian Prein b96d32996b *: Wrap lines at 80 columns where appropriate
Wrap lines at 80 columns where appropriate and I had the energy to think
about how/where to wrap.

There are still lines longer than that, which I plan to wrap in the
future. But that is enough for now.
2022-06-23 23:59:00 +02:00

134 lines
4.4 KiB
Bash

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-key -T copy-mode-vi MouseDragEnd1Pane \
send-keys -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'
# Set C-a as new prefix
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Split panes with > and <
unbind %
bind-key < split-window -v -c "#{pane_current_path}"
unbind '"'
bind-key > split-window -h -c "#{pane_current_path}"
# Create new window in current path
bind-key -T prefix c new-window -c "#{pane_current_path}"
# Resource config
bind-key -T prefix R source-file "$XDG_CONFIG_HOME/tmux/tmux.conf" \; \
display-message "Sourced $XDG_CONFIG_HOME/tmux/tmux.conf"
# Fullscreen pane (toggle)
bind-key -T prefix F resize-pane -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-key -n PPage copy-mode -u
# Repeatable window-navigation bindings
bind-key -r -T prefix n next-window
bind-key -r -T prefix C-n next-window
bind-key -r -T prefix p previous-window
bind-key -r -T prefix C-p previous-window
# Vim-bindings
# Enter copy-mode with Escape
bind-key -T prefix Escape copy-mode
# Start selection (e.g. visual mode) with `v`
unbind -T copy-mode-vi v
bind-key -T copy-mode-vi v send-keys -X begin-selection
# Yank into system clipboard
bind-key -T copy-mode-vi y send-keys -X copy-pipe "xclip -selection clipboard"
# Navigate panes with <prefix>-[hjkl]
# NOTE: C-[hjkl] (w/o prefix) moves through vim splits and tmux panes
# See vim-tmux-navigator
unbind -T prefix l
bind -T prefix h select-pane -L
bind -T prefix j select-pane -D
bind -T prefix k select-pane -U
bind -T prefix l select-pane -R
# Resize panes with Alt-Shift-[hjkl]
bind -n M-H resize-pane -L
bind -n M-J resize-pane -D
bind -n M-K resize-pane -U
bind -n M-L resize-pane -R
# Resize panes with Alt-Shift-<arrow>
bind -n M-S-Left resize-pane -L
bind -n M-S-Up resize-pane -D
bind -n M-S-Down resize-pane -U
bind -n M-S-Right resize-pane -R
# Change installation location of plugins
set-environment -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/tmux-yank'
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 -T prefix d
bind-key -T prefix d \
run-shell "$XDG_CONFIG_HOME/tmux/plugins/tmux-resurrect/scripts/save.sh" \; \
detach-client
## 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"