dotfiles/.tmux.conf

155 lines
5.8 KiB
Plaintext

# remap prefix to Control + Space
set -g prefix C-Space
bind C-Space send-prefix
unbind C-b
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" { send-keys C-h } { if -F '#{pane_at_left}' { } { select-pane -L }
}
bind-key -n 'C-j' if-shell "$is_vim" { send-keys C-j } { if -F '#{pane_at_bottom}' { } { select-pane -D }
}
bind-key -n 'C-k' if-shell "$is_vim" { send-keys C-k } { if -F '#{pane_at_top}' { } { select-pane -U }
}
bind-key -n 'C-l' if-shell "$is_vim" { send-keys C-l } { if -F '#{pane_at_right}' { } { select-pane -R } }
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
# vim like copy mode
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
setw -g mode-keys vi
# Mouse support - set to on if you want to use the mouse
setw -g mouse on
# source the .tmux.conf file with prefix + r
bind r source-file ~/.tmux.conf \; display "Configuration Reloaded!"
bind-key - split-window -v
bind-key '\' split-window -h
bind-key _ split-window -fv
bind-key | split-window -fh
# set -g lock-after-time 300
# set -g lock-command "asciiquarium"
# bind-key "'" choose-window
# bind-key '"' choose-session
# kill current pane/window
bind-key q confirm-before kill-pane
bind-key Q confirm-before kill-window
bind-key C-q confirm-before kill-pane
# no prefix, just c-x
bind -n C-x setw synchronize-panes
# reorder windows
bind-key -n C-S-Left swap-window -t -1\; select-window -t -1
bind-key -n C-S-Right swap-window -t +1\; select-window -t +1
set -g default-terminal "screen-256color"
# start session number from 1 rather than 0
# set -g base-index 1
# start pane number from 1 similar to windows
# setw -g pane-base-index 1
# highlight active pane
# set -g window-style 'fg=colour247,bg=colour236'
# set -g window-active-style 'fg=colour250,bg=black'
# set-option -g pane-active-border-style fg=red
# use <prefix> C-l to clear screen
bind C-l send-keys 'C-l'
# use <prefix> j for zooming the current pane
bind-key j if-shell "$is_vim" {
resize-pane -Z
send-keys C-w =
} {
resize-pane -Z
}
bind-key C-j if-shell "$is_vim" {
resize-pane -Z
send-keys C-w =
} {
resize-pane -Z
}
unbind z
# status bar theme
set -g status 'on'
set -g status-bg 'colour235'
set -g status-justify 'centre'
set -g status-style 'none'
set -g status-left-style 'none'
set -g status-left-length '100'
set -g status-right-style 'none'
set -g status-right-length '100'
set -g message-command-style fg='colour222',bg='colour238'
set -g message-style bg='colour238',fg='colour222'
set -g pane-active-border-style fg='colour154'
set -g pane-border-style fg='colour238'
setw -g window-status-style fg='colour121',bg='colour235','none'
setw -g window-status-activity-style bg='colour235',fg='colour154','none'
setw -g window-status-separator ''
set -g status-left '#[fg=colour0,bg=colour3] #S #[fg=colour3,bg=colour4,nobold,nounderscore,noitalics]#[fg=colour0,bg=colour4] #W #[fg=colour4,bg=default,nobold,nounderscore,noitalics]'
# above status + whoami and uptime
# set -g status-left '#[fg=colour232,bg=colour154] #S #[fg=colour154,bg=colour238,nobold,nounderscore,noitalics]#[fg=colour222,bg=colour238] #W #[fg=colour238,bg=colour235,nobold,nounderscore,noitalics]#[fg=colour121,bg=colour235] #(whoami)  #(uptime | cut -d " " -f 1,2,3) #[fg=colour235,bg=colour235,nobold,nounderscore,noitalics]'
setw -g window-status-current-format '#[fg=colour0,bg=colour4,bold,nounderscore,noitalics]#[fg=colour0,bg=colour4] #I  #W  #F #[fg=colour4,bg=default,nobold,nounderscore,noitalics]'
setw -g window-status-format '#[fg=colour0,bg=colour10,nobold,nounderscore,noitalics]#[fg=colour0,bg=colour10] #I  #W #[fg=colour10,bg=default,nobold,nounderscore,noitalics]'
set -g status-right '#[fg=colour6,bg=default,nobold,nounderscore,noitalics]#[fg=colour0,bg=colour6] %R  %a  %h-%d #[fg=colour4,bg=colour6,nobold,nounderscore,noitalics]#[fg=colour0,bg=colour4] #{battery_color_charge_fg}#[bg=colour4]#{battery_icon} #{battery_percentage}#[fg=colour1,bg=colour4,nobold,nounderscore,noitalics] #{prefix_highlight}'
set -g status-interval 1
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{b:pane_current_path}'
# Plugin Customizations
set -g @prefix_highlight_fg 'colour0'
set -g @prefix_highlight_bg 'colour1'
set -g @prefix_highlight_sync_mode_attr 'fg=colour0,bg=colour1,bold'
set -g @prefix_highlight_copy_mode_attr 'fg=colour0,bg=colour1,bold'
set -g @prefix_highlight_show_copy_mode 'on'
set -g @prefix_highlight_show_sync_mode 'on'
set -g @prefix_highlight_sync_prompt 'SYNC'
set -g @resurrect-strategy-vim 'session'
set -g @batt_icon_status_charging '⚡'
# set -g @continuum-boot 'on'
# set -g @continuum-restore 'on'
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-open'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-battery'
run '~/.tmux/plugins/tpm/tpm'