# ████████╗███╗ ███╗██╗ ██╗██╗ ██╗ # ╚══██╔══╝████╗ ████║██║ ██║╚██╗██╔╝ # ██║ ██╔████╔██║██║ ██║ ╚███╔╝ # ██║ ██║╚██╔╝██║██║ ██║ ██╔██╗ # ██║ ██║ ╚═╝ ██║╚██████╔╝██╔╝ ██╗ # ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ #―――――――――――――――――――――――――――――――――――――――――― ### Options ### # Setting the Prefix from Ctrl+b to Ctrl+s unbind C-b set -g prefix C-s #set -g prefix M-Space # Ensure that we can send Ctrl+s to other apps bind C-s send-prefix # Send the prefix to client inside window (nested tmux) #bind-key -n C-a send-prefix is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" bind -n C-a if-shell "$is_vim" "send-keys C-a" "send-prefix" # Disable local tmux keys (nested tmux) bind -T root F12 \ set prefix None \;\ set key-table off \;\ if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\ refresh-client -S \;\ bind -T off F12 \ set -u prefix \;\ set -u key-table \;\ refresh-client -S # Setting the delay between Prefix and Command set -sg escape-time 10 #set-option -sg escape-time 10 # Reload tmux with r bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!" # Use L to clear terminal bind -r L send-keys 'C-l' # Rename current window (Ctrl + A, A) bind R rename-window '' \; \ command-prompt -I "#W" "rename-window -- '%%'" # Renumber all windows when one is killed set -g renumber-windows on # Mouse set -g mouse on #set -g mouse-select-pane on #set -g mouse-resize-pane on #set -g mouse-select-window on # Scrollback #set -g history-limit 10000 # Sane scrolling set -g terminal-overrides 'xterm*:smcup@:rmcup@' # Sane scrolling set -g terminal-overrides 'xterm*:smcup@:rmcup@' bind -n WheelUpPane { if -F '#{==:#{window_name},nvim}' { #send-keys -M send-keys Up } { copy-mode -e } } bind -n WheelDownPane { if -F '#{==:#{window_name},nvim}' { #send-keys -M send-keys Down } { copy-mode -e } } # Shift up/down copy-mode without prefix bind-key -n S-Up copy-mode \; send-key Up bind-key -n S-Down copy-mode \; send-key Down bind-key -n Pageup copy-mode \; send-key Pageup bind-key -n Pagedown copy-mode \; send-key Pagedown is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" #bind -n M-k if-shell "$is_vim" "send-keys Pageup" "copy-mode -u" bind -n Pageup if-shell "$is_vim" "send-keys Pageup" "copy-mode -u" bind -n S-Pageup if-shell "$is_vim" "send-keys Pageup" "copy-mode -u" bind -n S-Pagedown send-keys Pagedown #bind -n M-j send-keys Pagedown # Focus events, allow supported requests from applications to passthrough/run in tmux set-option -g focus-events on # Update the TERM variable of terminal emulator when creating a new session or attaching a existing session set -g update-environment 'DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY TERM' #―――――――――――――――――――――――――――――――――――――――――― ### Window Movement/Control ### # Aggressive resizing, useful when using "grouped sessions" and multi-monitor setup setw -g aggressive-resize on # Popup scratch session #bind -n M-g display-popup -E "tmux new-session -A -s scratch" # Toggle popup scratch session bind-key -n M-g if-shell -F '#{==:#{session_name},note}' { detach-client } { display-popup -E "tmux new-session -A -s note" } # Non-popup #bind C-k new-window -n "session-switcher" "\ # tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ # sed '/^$/d' |\ # fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\ # xargs tmux switch-client -t" # List sessions bind -n M-f display-popup -E "\ tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ sed '/^$/d' |\ fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\ xargs tmux switch-client -t" # Quick window select bind -n M-? list-keys bind -n M-0 select-window -t :=0 bind -n M-1 select-window -t :=1 bind -n M-2 select-window -t :=2 bind -n M-3 select-window -t :=3 bind -n M-4 select-window -t :=4 bind -n M-5 select-window -t :=5 bind -n M-6 select-window -t :=6 bind -n M-7 select-window -t :=7 bind -n M-8 select-window -t :=8 bind -n M-9 select-window -t :=9 #―――――――――――――――――――――――――――――――――――――――――― ### Pane Movement/Control ### # Smart pane switching with awareness of Vim splits. # See: https://github.com/christoomey/vim-tmux-navigator # Navigate across tmux-vim is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" # {{{ keybinds: select-pane bind -Tnav h select-pane -L bind h select-pane -L bind -Tnav C-h select-pane -L bind C-h select-pane -L bind -Tnav j select-pane -D bind j select-pane -D bind -Tnav C-j select-pane -D bind C-j select-pane -D bind -Tnav k select-pane -U bind k select-pane -U bind -Tnav C-k select-pane -U bind C-k select-pane -U bind -Tnav l select-pane -R bind l select-pane -R bind -Tnav C-l select-pane -R bind C-l select-pane -R # keybinds: select-pane }}} # {{{ keybinds: split-window bind -Tnav "\\" split-window -h -c "#{pane_current_path}" # vertical bind "\\" split-window -h -c "#{pane_current_path}" # vertical bind -Tnav "|" split-window -fh -c "#{pane_current_path}" # full vertical bind "|" split-window -fh -c "#{pane_current_path}" # full vertical bind -Tnav "-" split-window -v -c "#{pane_current_path}" # horizontal bind "-" split-window -v -c "#{pane_current_path}" # horizontal bind -Tnav "_" split-window -fv -c "#{pane_current_path}" # full horizontal bind "_" split-window -fv -c "#{pane_current_path}" # full horizontal # keybinds: split-window }}} # {{{ keybinds: resize-pane bind -r -Tnav M-h resize-pane -L 10 bind -r M-h resize-pane -L 10 bind -r -Tnav M-j resize-pane -D 5 bind -r M-j resize-pane -D 5 bind -r -Tnav M-k resize-pane -U 5 bind -r M-k resize-pane -U 5 bind -r -Tnav M-l resize-pane -R 10 bind -r M-l resize-pane -R 10 # keybinds: resize-pane }}} # Hide a pane and bring it back with ! and @ respectively bind-key ! break-pane -d -n _hidden_pane bind-key @ join-pane -s $.0 # Send Pane to another session/window bind-key = command-prompt -p "send pane to:" "join-pane -t '%%'" #―――――――――――――――――――――――――――――――――――――――――― ### Copy Mode (Copy/Paste) ### # Set Vi copy mode, use [ to enter copy mode setw -g mode-keys vi # `:list-keys -T copy-mode-vi` to confirm # Change selection and enter to vi keybinding bind-key -T copy-mode-vi 'v' send -X begin-selection bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel # Copy to system clipboard (requires xclip) if-shell -b 'echo $XDG_SESSION_TYPE | grep -q x11' "\ bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard > /dev/null'; \ bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard > /dev/null'; \ bind-key C-M-v run 'xclip -out -selection clipboard | tmux load-buffer - ; tmux paste-buffer'" # Wayland support if-shell -b 'echo $XDG_SESSION_TYPE | grep -q wayland' "\ bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'wl-copy'; \ bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'wl-copy'; \ bind-key C-p run 'wl-paste --no-newline | tmux load-buffer - ; tmux paste-buffer'" "\ \ bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'cat - >/dev/clipboard'; \ bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'cat - >/dev/clipboard'; \ bind-key C-M-v run 'cat /dev/clipboard | tmux load-buffer - ; tmux paste-buffer'" # ### Colors ### ## Assume external terminal supports the 256 colors palette (when TERM=xterm-256color) #set -sa terminal-features ",xterm-256color:256" ## Assume external terminal supports RGB colors (when TERM=xterm-256color) #set -sa terminal-features ",xterm-256color:RGB" # ## Set TERM for proper colors #set -g default-terminal "tmux-256color" set -g default-terminal "xterm-256color" # Set 256 color terminal #set-option -sa terminal-overrides ",tmux-256color:Tc" #set-option -sa terminal-overrides ",xterm*:Tc,alacritty*:Tc" # Colors for pane borders(default) setw -g pane-border-style fg=white setw -g pane-active-border-style fg=green # Active pane normal, other shaded out setw -g window-style fg=colour240 setw -g window-active-style fg=white # ### Status ### set -g status-position bottom # [top, bottom] set -g status on #set -g status-interval 1 set -g status-interval 500 set -g status-style fg=#50fa7b,bg=default ## Left #set -g status-left "" set -g status-left-length 60 #set -g status-left "#[fg=#50fa7b,bg=default]#[bg=#50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]" set -g status-left "#(cat ~/.vi-mode | awk '/-- NORMAL --/ {print \"#[fg=#39BAE6]#[bg=default]#[bg=#39BAE6,fg=#000000] ❐ #S #[fg=#39BAE6,bg=default]\"} /-- INSERT --/ {print \"#[fg=#50fa7b]#[bg=default]#[bg=#50fa7b,fg=#000000] ❐ #S #[fg=#50fa7b,bg=default]\"}')" ## Centre #set -g window-status-current-format "#[bg=default,fg=#50fa7b]#[fg=black,bg=#50fa7b] #I:#W #[bg=default,fg=#50fa7b]" set -g window-status-current-format "#(cat ~/.vi-mode | awk '/-- NORMAL --/ {print \"#[fg=#39BAE6]#[bg=default]#[fg=#000000,bg=#39BAE6] #I:#W #[bg=default,fg=#39BAE6]\"} /-- INSERT --/ {print \"#[fg=#50fa7b]#[bg=default]#[fg=#000000,bg=#50fa7b] #I:#W #[bg=default,fg=#50fa7b]\"}')" set -g status-justify absolute-centre ## Right set-option -g status-right "" set -g status-right-length 60 #set -g status-right "#[fg=#50fa7b,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,} #[bg=default,fg=#50fa7b]#[bg=#50fa7b,fg=black] %H:%M #[bg=default,fg=#50fa7b]" local_keys_off="#[fg=#50fa7b,bg=default]#([ $(tmux show-option -qv key-table) = 'off' ] && echo 'OFF')#[default]" set -g status-right "$local_keys_off #(cat ~/.vi-mode | awk '/-- NORMAL --/ {print \"#[fg=#50fa7b,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,} #[fg=#39BAE6]#[bg=default]#[bg=#39BAE6,fg=#000000] %H:%M #[bg=default,fg=#39BAE6]\"} /-- INSERT --/ {print \"#[fg=#39BAE6,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,} #[fg=#50fa7b]#[bg=default]#[bg=#50fa7b,fg=#000000] %H:%M #[bg=default,fg=#50fa7b]\"}')" #set -g status-right "#[fg=white,bg=black]#(cat ~/.vi-mode)" #set -g status-right "#[fg=white,bg=black]#(cat ~/.vi-mode | awk '/-- NORMAL --/ {print \"#[fg=blue]#[bg=black]-- NORMAL --\"} /-- INSERT --/ {print \"#[fg=green]#[bg=black]-- INSERT --\"}')" ## Reload Status with IP addr, Cpu, Mem and Date bind a run-shell ~/.config/tmux/tmux-toggle-option.sh ## Reload Config/Status silently bind b source-file ~/.config/tmux/tmux.conf set-option -g default-shell "/usr/bin/zsh" #―――――――――――――――――――――――――――――――――――――――――― ### Plugin Install ### 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 "christoomey/vim-tmux-navigator" #set -g @plugin "tmux-plugins/tmux-yank" #set -g @plugin 'srdusr/tmux-vi-mode' #set -g @plugin 'vi-mode ~/.config/tmux/plugins/vi-mode.sh' #―――――――――――――――――――――――――――――――――――――――――― ### Plugins Settings ### # Plugin to save and restore tmux sessions after restart # * Save with: + Ctrl-s # * Restore with: + Ctlr-r # Change default save and restore keybindings set -g @resurrect-save "W" # + W set -g @resurrect-restore "E" # + E # Restore vim and nvim sessions as well # For vim: set -g @resurrect-strategy-vim "session" # For neovim: set -g @resurrect-strategy-nvim "session" # Automatic restore #set -g @continuum-restore "on" #set -g @continuum-boot "on" # Restore Panes set -g @resurrect-capture-pane-contents "on" # This is a hook for tmux-resurrect which tells it to kill session 0 before restoring the panels set -g @resurrect-hook-pre-restore-pane-processes "tmux switch-client -n && tmux kill-session -t=0" # Plugin uninstall # Delete or comment out the plugin in .tmux.conf. # Press + alt + u to remove the plugin. # TMUX plugin manager (keep at the bottom of tmux.conf) #run "~/.config/tmux/plugins/tpm/tpm" if "test ! -d ~/.config/tmux/plugins/tpm" \ "run 'git clone https://github.com/tmux-plugins/tpm ~/.config/tmux/plugins/tpm && ~/.config/tmux/plugins/tpm/bin/install_plugins'" run -b "~/.config/tmux/plugins/tpm/tpm"