Restore {,neo}vim sessions with the help of [tpope/vim-obsession][1]
[1]: https://github.com/tpope/vim-obsession
116 lines
3.8 KiB
Bash
116 lines
3.8 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}"
|
|
|
|
# Change panes with Alt-<arrow>
|
|
bind -n M-Left select-pane -L
|
|
bind -n M-Right select-pane -R
|
|
bind -n M-Up select-pane -U
|
|
bind -n M-Down select-pane -D
|
|
|
|
# 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
|
|
|
|
# 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 hjkl
|
|
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
|
|
# Allow holding Ctrl after pressing the prefix
|
|
bind -T prefix C-h select-pane -L
|
|
bind -T prefix C-j select-pane -D
|
|
bind -T prefix C-k select-pane -U
|
|
bind -T prefix C-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 '~/.config/tmux/plugins/'
|
|
|
|
## Plugins
|
|
set -g @plugin 'tmux-plugins/tpm'
|
|
set -g @plugin 'tmux-plugins/tmux-sensible'
|
|
set -g @plugin 'tmux-plugins/tmux-resurrect'
|
|
set -g @plugin 'tmux-plugins/tmux-continuum'
|
|
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
|
|
|
|
# Capture pane content
|
|
set -g @resurrect-capture-pane-contents 'on'
|
|
# Change keybindings
|
|
set -g @resurrect-save 'C-s'
|
|
set -g @resurrect-restore 'C-s'
|
|
# 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'
|
|
|
|
## Theming (inspired by https://github.com/Who23/dots/blob/21976e76644d8d9261ebdcf61733d2181a1612eb/tmux.conf)
|
|
set -g status-bg black
|
|
set -g status-fg white
|
|
|
|
# set -g status-right "Continuum status: #{continuum_status}"
|
|
set -g @prefix_highlight_fg 'black'
|
|
set -g @prefix_highlight_bg 'yellow'
|
|
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=yellow]#[fg=black]#[bg=yellow]#I #W#[fg=yellow]#[bg=black] "
|
|
set -g window-status-format "#[fg=brightblack]#[fg=white]#[bg=brightblack]#I #W#[fg=brightblack]#[bg=black] "
|
|
|
|
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
|
|
run -b '~/.config/tmux/plugins/tpm/tpm'
|