You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
4.0 KiB

# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Start window numbering at 1
set -g base-index 1
# Replace "xterm-256color" with the output of "echo $TERM"
set-option -ga terminal-overrides ",xterm-256color:Tc"
set-option -ga terminal-overrides ",rxvt-unicode-256color:Tc"
# Enable mouse support
set -g mouse on
# Switch to a window with alt+num. Automatically creates the window if it doesn't already exist
bind -n M-1 if-shell 'tmux select-window -t :1' '' 'new-window -t :1'
bind -n M-2 if-shell 'tmux select-window -t :2' '' 'new-window -t :2'
bind -n M-3 if-shell 'tmux select-window -t :3' '' 'new-window -t :3'
bind -n M-4 if-shell 'tmux select-window -t :4' '' 'new-window -t :4'
bind -n M-5 if-shell 'tmux select-window -t :5' '' 'new-window -t :5'
bind -n M-6 if-shell 'tmux select-window -t :6' '' 'new-window -t :6'
bind -n M-7 if-shell 'tmux select-window -t :7' '' 'new-window -t :7'
bind -n M-8 if-shell 'tmux select-window -t :8' '' 'new-window -t :8'
bind -n M-9 if-shell 'tmux select-window -t :9' '' 'new-window -t :9'
bind -n M-0 if-shell 'tmux select-window -t :10' '' 'new-window -t :10'
# Move pane to a window using alt+shift+num. Automatically creates/destroys windows
# This works by first trying to move the pane to the specified window using `join-pane`. If that fails we assume it's
# because the destination window doesn't exist, so we try `break-pane` instead. Finally, if that fails it is also
# assumed that this is the last pane in the window, meaning we can simply move the window our pane is in to the
# destination window using `move-window`.
# This might fail if our assumptions are wrong and the destination window already exists, even though all our previous
# attempts to move the pane failed.
bind -n M-'!' if-shell 'tmux join-pane -t :1' '' 'if-shell "tmux break-pane -t :1" "" "move-window -t :1"'
bind -n M-'"' if-shell 'tmux join-pane -t :2' '' 'if-shell "tmux break-pane -t :2" "" "move-window -t :2"'
bind -n M-'#' if-shell 'tmux join-pane -t :3' '' 'if-shell "tmux break-pane -t :3" "" "move-window -t :3"'
bind -n M-'¤' if-shell 'tmux join-pane -t :4' '' 'if-shell "tmux break-pane -t :4" "" "move-window -t :4"' # TODO: This is broken in Alacritty.
bind -n M-'%' if-shell 'tmux join-pane -t :5' '' 'if-shell "tmux break-pane -t :5" "" "move-window -t :5"'
bind -n M-'&' if-shell 'tmux join-pane -t :6' '' 'if-shell "tmux break-pane -t :6" "" "move-window -t :6"'
bind -n M-'/' if-shell 'tmux join-pane -t :7' '' 'if-shell "tmux break-pane -t :7" "" "move-window -t :7"'
bind -n M-'(' if-shell 'tmux join-pane -t :8' '' 'if-shell "tmux break-pane -t :8" "" "move-window -t :8"'
bind -n M-')' if-shell 'tmux join-pane -t :9' '' 'if-shell "tmux break-pane -t :9" "" "move-window -t :9"'
bind -n M-'=' if-shell 'tmux join-pane -t :10' '' 'if-shell "tmux break-pane -t :10" "" "move-window -t :10"'
# Smart pane switching with awareness of Vim splits.
# See:
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n M-Left if-shell "$is_vim" "send-keys M-Left" "select-pane -L"
bind-key -n M-Down if-shell "$is_vim" "send-keys M-Down" "select-pane -D"
bind-key -n M-Up if-shell "$is_vim" "send-keys M-Up" "select-pane -U"
bind-key -n M-Right if-shell "$is_vim" "send-keys M-Right" "select-pane -R"
bind-key -n M-Tab if-shell "$is_vim" "send-keys M-Tab" "select-pane -l"
bind-key -T copy-mode-vi M-Left select-pane -L
bind-key -T copy-mode-vi M-Down select-pane -D
bind-key -T copy-mode-vi M-Up select-pane -U
bind-key -T copy-mode-vi M-Right select-pane -R
bind-key -T copy-mode-vi M-Tab select-pane -l
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'arcticicestudio/nord-tmux'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'