# ████████╗███╗ ███╗██╗ ██╗██╗ ██╗ # ╚══██╔══╝████╗ ████║██║ ██║╚██╗██╔╝ # ██║ ██╔████╔██║██║ ██║ ╚███╔╝ # ██║ ██║╚██╔╝██║██║ ██║ ██╔██╗ # ██║ ██║ ╚═╝ ██║╚██████╔╝██╔╝ ██╗ # ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ #―――――――――――――――――――――――――――――――――――――――――― ### 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 # 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 ~/.tmux.conf \; display "Reloaded!" bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!" # Use Ctrl+l to clear terminal bind C-l send-keys 'C-l' # Scrollback #set -g history-limit 10000 # Mouse set -g mouse on #set -g mouse-select-pane on #set -g mouse-resize-pane on #set -g mouse-select-window on # 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},scratch}' { detach-client } { display-popup -E "tmux new-session -A -s scratch" } # 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" # Popup 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-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 bind -n M-0 select-window -t :=0 #―――――――――――――――――――――――――――――――――――――――――― ### Pane Movement/Control ### # 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|l?n?vim?x?)(diff)?$'" bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' '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'" # Copy Mode vi-directional keys 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 bind-key -T copy-mode-vi 'C-\' select-pane -l # Change horizontal split % and Vertical split " to h and v respectively and change current working directory bind v split-window -h -c "#{pane_current_path}" bind h split-window -v -c "#{pane_current_path}" # Pane resizing, then shift + vi-directional keys, default is D,U,L,R bind -r H resize-pane -L 20 bind -r J resize-pane -D 20 bind -r K resize-pane -U 20 bind -r L resize-pane -R 20 # Pane resizing, then alt + vi-directional keys bind-key M-j resize-pane -D 5 bind-key M-k resize-pane -U 5 bind-key M-h resize-pane -L 5 bind-key M-l resize-pane -R 5 # 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 j 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 ### # 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-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]" ## Centre set -g window-status-current-format "#[bg=default,fg=#50fa7b]#[fg=black,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]" ## 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 #―――――――――――――――――――――――――――――――――――――――――― ### 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" #―――――――――――――――――――――――――――――――――――――――――― ### 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 -b "~/.tmux/plugins/tpm/tpm" run -b "~/.config/tmux/plugins/tpm/tpm" #――――――――――――――――――――――――――――――――――――――――――