# ========================== # === General settings === # ========================== # xterm-256color needed for vim to behave: set -g default-terminal "xterm-256color" set -g history-limit 20000 set -g buffer-limit 20 set -sg escape-time 10 set -g display-time 1500 set -g remain-on-exit off set -g repeat-time 300 setw -g allow-rename on setw -g automatic-rename off set -g allow-set-title on setw -g aggressive-resize on set -g renumber-windows #set -g default-path "~" # Change prefix key to C-a, easier to type, same to "screen" unbind C-b set -g prefix C-a bind C-a last-window bind a send-prefix # Set parent terminal title to reflect current window in tmux session set -g set-titles on set -g set-titles-string "#h/#S ⎨#T⎬" # Start index of window/pane with 1, because we're humans, not computers (yet) # set -g base-index 1 # setw -g pane-base-index 1 # Enable mouse support - See bind set -g mouse on set -g focus-events on set-hook -g -w pane-focus-in "set-option -Fw pane-border-status '#{?#{e|>:#{window_panes},1},top,off}'" set -g pane-border-format "#{pane_index}─#T" set -g display-panes-time 10000 # ========================== # === Key bindings === # ========================== # Unbind default key bindings, we're going to override unbind c unbind "\$" # rename-session unbind , # rename-window unbind % # split-window -h unbind '"' # split-window unbind \} # swap-pane -D unbind \{ # swap-pane -U unbind [ # paste-buffer unbind ] unbind "'" # select-window unbind p # previous-window unbind l # last-window unbind M-n # next window with alert unbind M-p # next window with alert unbind o # focus thru panes unbind & # kill-window unbind "#" # list-buffer unbind = # choose-buffer unbind z # zoom-pane unbind M-Up # resize 5 rows up unbind M-Down # resize 5 rows down unbind M-Right # resize 5 rows right unbind M-Left # resize 5 rows left bind m set mouse\; display-message "Mouse #{?mouse,On,Off}" # Kill pane/window/session shortcuts bind k kill-pane bind K kill-window unbind "\\" # zoom-pane bind C-"\\" confirm-before -p "Really quit and kill all your windows [y/n]" kill-session bind "\\" confirm-before -p "Really quit and kill all your windows [y/n]" kill-session bind C-x confirm-before -p "kill other windows? (y/n)" "kill-window -a" # Edit configuration and reload bind C-e new-window -n 'tmux.conf' "sh -c '\${EDITOR:-vim} ~/.tmux.conf && tmux source ~/.tmux.conf && tmux display \"Config reloaded\"'" # Reload tmux configuration bind C-r source-file ~/.tmux.conf \; display "Config reloaded" # new window and retain cwd and set default name to blank bind c new-window -c "#{pane_current_path}" -n '' # Prompt to rename window right after it's created # set-hook -g after-new-window 'command-prompt -I "#{window_name}" "rename-window '%%'"' # Rename session and window bind A command-prompt -p "Set window's title to:" "rename-window '%%'" bind r command-prompt -p "Set window's title to:" "rename-window '%%'" bind R command-prompt -I "#{session_name}" "rename-session '%%'" # Split panes bind | split-window -h -c "#{pane_current_path}" bind - split-window -v -c "#{pane_current_path}" bind '"' choose-tree -wZ bind S choose-window "join-pane -v -s "%%"" bind V choose-window "join-pane -h -s "%%"" bind B command-prompt -p "Break pane to new window (name):" "break-pane -n '%%'" bind ! break-pane -n '' # Select pane and windows bind -r C-[ previous-window bind -r C-] next-window bind -r [ select-pane -t :.- bind -r ] select-pane -t :.+ bind -r C-o swap-pane -D # Zoom pane bind + resize-pane -Z bind = resize-pane -Z # Link window # bind L command-prompt -p "Link window from (session:window): " "link-window -s %% -a" # Merge session with another one (e.g. move all windows) # If you use adhoc 1-window sessions, and you want to preserve session upon exit # but don't want to create a lot of small unnamed 1-window sessions around # move all windows from current session to main named one (dev, work, etc) bind C-u command-prompt -p "Session to merge with: " \ "run-shell 'yes | head -n #{session_windows} | xargs -I {} -n 1 tmux movew -t %%'" # Detach from session bind d detach bind D if -F '#{session_many_attached}' \ 'confirm-before -p "Detach other clients? (y/n)" "detach -a"' \ 'display "Session has only 1 client attached"' # Hide status bar on demand #bind C-s if -F '#{s/off//:status}' 'set status off' 'set status on' bind-key -n MouseUp2Status kill-window -t= bind-key -n MouseUp2StatusDefault new-window -a -c "#{pane_current_path}" -n '' bind -n MouseDown1Status selectw \; set -F @drag_window '#{window_id}' bind -n MouseDrag1Status run -C 'swapw -ds#{@drag_window}' bind -n MouseDragEnd1Status set -u @drag_window # ================================================== # === Window monitoring for activity and silence === # ================================================== #bind m setw monitor-activity \; display-message 'Monitor window activity [#{?monitor-activity,ON,OFF}]' #bind M if -F '#{monitor-silence}' \ # 'setw monitor-silence 0 ; display-message "Monitor window silence [OFF]"' \ # 'command-prompt -p "Monitor silence: interval (s)" "setw monitor-silence %%"' # Activity bell and whistles set -g visual-activity on # ================================================ # === Copy mode, scroll and clipboard === # ================================================ # Prefer vi style key table setw -g mode-keys vi bind p paste-buffer bind C-p choose-buffer # trigger copy mode by bind -n S-Pageup copy-mode # Scroll up/down by 1 line, half screen, whole screen bind -T copy-mode-vi M-Up send-keys -X scroll-up bind -T copy-mode-vi M-Down send-keys -X scroll-down bind -T copy-mode-vi M-PageUp send-keys -X halfpage-up bind -T copy-mode-vi M-PageDown send-keys -X halfpage-down bind -T copy-mode-vi PageDown send-keys -X page-down bind -T copy-mode-vi PageUp send-keys -X page-up # When scrolling with mouse wheel, reduce number of scrolled rows per tick to "2" (default is 5) bind -T copy-mode-vi WheelUpPane select-pane \; send-keys -X -N 3 scroll-up bind -T copy-mode-vi WheelDownPane select-pane \; send-keys -X -N 3 scroll-down # wrap default shell in reattach-to-user-namespace if available # there is some hack with `exec & reattach`, credits to "https://github.com/gpakosz/.tmux" # windows are not renamed to "reattach-to-user-namespace" #if -b "command -v reattach-to-user-namespace > /dev/null 2>&1" \ # "run 'tmux set -g default-command \"exec $(tmux show -gv default-shell) 2>/dev/null & reattach-to-user-namespace -l $(tmux show -gv default-shell)\"'" set -g set-clipboard on # ===================================== # === Theme === # ===================================== # Feel free to NOT use this variables at all (remove, rename) # this are named colors, just for convenience color_orange="colour166" # 208, 166 color_purple="colour134" # 135, 134 color_green="colour076" # 070 color_blue="colour39" color_yellow="colour220" color_red="colour160" color_black="colour232" color_white="white" # 015 # This is a theme CONTRACT, you are required to define variables below # Change values, but not remove/rename variables itself color_dark="$color_black" color_light="$color_white" #color_session_text="$color_blue" color_session_text="colour33" #color_status_text="colour245" color_status_text="white" color_main="$color_orange" color_secondary="$color_purple" color_level_ok="$color_green" color_level_warn="$color_yellow" color_level_stress="$color_red" color_window_off_indicator="colour088" color_window_off_status_bg="colour238" color_window_off_status_current_bg="colour254" color_tab_inactive="colour237" # ===================================== # === Appearence and status bar === # ====================================== set -g mode-style "fg=default,bg=$color_main" # command line style set -g message-style "fg=$color_main,bg=$color_dark" # status line style set -g status-style "fg=$color_status_text,bg=$color_dark" # window segments in status line set -g window-status-separator "" # setw -g window-status-style "fg=$color_status_text,bg=$color_dark" #setw -g window-status-format " #I#{?window_last_flag,⸤,.} #W |" #setw -g window-status-format "#[fg=$color_dark,bg=$color_dark]🬿#[default] #I#{?window_last_flag,⸤,.} #W #[fg=$color_dark,bg=$color_dark]🭊#[default]|" setw -g window-status-format "#[fg=$color_dark,bg=$color_tab_inactive]🬿#[bg=$color_tab_inactive,fg=white] #I#{?window_last_flag,⸤,.} #W #[fg=$color_dark,bg=$color_tab_inactive]🭊#[default] " #setw -g window-status-format " #I#{?window_last_flag,,} #W " setw -g window-status-current-style "fg=$color_light,bold,bg=$color_main" #setw -g window-status-current-format "#[fg=$color_dark,bg=$color_main] #Iˢ #W #[fg=$color_status_text,bg=$color_dark]\|#[default]" #setw -g window-status-current-format "#[fg=$color_dark,bg=terminal] #Iˢ #W #[fg=$color_status_text,bg=$color_dark]\|#[default]" #setw -g window-status-current-format "#[fg=$color_dark,bg=$color_main]🬿 #Iˢ #W 🭊#[fg=$color_status_text,bg=$color_dark]|#[default]" #setw -g window-status-current-format "#[fg=$color_dark,bg=terminal]🬿 #Iˢ #W 🭊#[fg=$color_status_text,bg=$color_dark]|#[default]" setw -g window-status-current-format "#[fg=$color_dark,bg=terminal]🬿 #Iˢ #W 🭊#[fg=$color_status_text,bg=$color_dark] #[default]" # when window has monitoring notification setw -g window-status-activity-style "fg=$color_main" # outline for active pane setw -g pane-active-border-style "fg=$color_main" # general status bar settings set -g status on set -g status-interval 5 set -g status-position bottom set -g status-justify left set -g status-right-length 100 # define widgets we're going to use in status bar # note, that this is not the complete list, some of them are loaded from plugins wg_session="#[fg=$color_session_text] #h #[default]│" #wg_battery="#{battery_status_fg} #{battery_icon} #{battery_percentage}" #wg_date="#[fg=$color_secondary]%h %d %H:%M#[default]" wg_is_zoomed="#[fg=$color_dark,bg=$color_secondary]#{?window_zoomed_flag, 🔍 ,}#[default]" # TODO: highlighted for nested local session as well wg_is_keys_off="#[fg=white,bg=$color_window_off_indicator]#([ $(tmux show-option -qv key-table) = 'off' ] && echo ' 🔒⌨️ ')#[default]" set -g status-left "$wg_session" set -g status-right "#{prefix_highlight} $wg_is_keys_off$wg_is_zoomed │#[fg=$color_session_text] #S #[default]" # ===================================== # === Renew environment === # ===================================== set -g update-environment \ "DISPLAY\ GDK_CORE_DEVICE_EVENTS\ __GL_MaxFramesAllowed\ GTK2_RC_FILES\ GTK_IM_MODULE\ GTK_RC_FILES\ KDE_APPLICATIONS_AS_SCOPE\ KDEDIRS\ KDE_FULL_SESSION\ KDE_SESSION_UID\ KDE_SESSION_VERSION\ LANG\ LANGUAGE\ LC_MEASUREMENT\ LC_NUMERIC\ SSH_AGENT_PID\ SSH_ASKPASS\ SSH_AUTH_SOCK\ SSH_CLIENT\ SSH_CONNECTION\ SSH_TTY\ VSCODE_GIT_ASKPASS_EXTRA_ARGS\ VSCODE_GIT_ASKPASS_MAIN\ VSCODE_GIT_ASKPASS_NODE\ VSCODE_GIT_IPC_HANDLE\ VSCODE_INJECTION\ VSCODE_IPC_HOOK_CLI\ VSCODE_PYTHON_AUTOACTIVATE_GUARD\ WINDOWID\ XAUTHORITY\ XCURSOR_SIZE\ XCURSOR_THEME\ XDG_CONFIG_DIRS\ XDG_CURRENT_DESKTOP\ XDG_DATA_DIRS\ XDG_MENU_PREFIX\ XDG_RUNTIME_DIR\ XDG_SEAT\ XDG_SEAT_PATH\ XDG_SESSION_CLASS\ XDG_SESSION_DESKTOP\ XDG_SESSION_ID\ XDG_SESSION_PATH\ XDG_SESSION_TYPE\ XDG_VTNR" bind '$' run "~/.tmux/renew_env.sh" # ============================================== # === Nesting local and remote sessions === # ============================================== # Session is considered to be remote when we ssh into host #if-shell 'test -n "$SSH_CLIENT"' \ # 'source-file ~/.tmux/tmux.remote.conf' # We want to have single prefix key "C-a", usable both for local and remote session # we don't want to "C-a" + "a" approach either # Idea is to turn off all key bindings and prefix handling on local session, # so that all keystrokes are passed to inner/remote session # see: toggle on/off all keybindings · Issue #237 · tmux/tmux - https://github.com/tmux/tmux/issues/237 # Also, change some visual styles when window keys are off ### bind -T root F12 \ ### set prefix None \;\ ### set key-table off \;\ ### set status-style "fg=$color_status_text,bg=$color_window_off_status_bg" \;\ ### set window-status-current-format "#[fg=$color_dark,bg=$color_window_off_status_current_bg] #Iˢ #W #[fg=$color_light,bg=$color_window_off_status_bg]#[default]" \;\ ### set window-status-current-style "fg=$color_light,bold,bg=$color_window_off_status_current_bg" \;\ ### if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\ ### refresh-client -S \;\ bind -T root F12 \ set prefix None \;\ set key-table off \;\ set status-style "fg=$color_status_text,bg=$color_window_off_status_bg" \;\ set window-status-format "#[fg=$color_dark,bg=$color_window_off_status_bg]🬿#[bg=$color_window_off_status_bg,fg=$color_status_text] #I#{?window_last_flag,⸤,.} #W #[fg=$color_dark,bg=$color_window_off_status_bg]🭊#[default] " \;\ set window-status-current-format "#[fg=$color_dark,bg=$color_window_off_status_bg]🬿 #Iˢ #W 🭊#[fg=$color_status_text,bg=$color_dark] #[default]" \;\ set window-status-current-style "fg=$color_light,bold,bg=$color_window_off_status_current_bg" \;\ if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\ refresh-client -S \;\ bind -T off F12 \ set -u prefix \;\ set -u key-table \;\ set -u status-style \;\ set -u window-status-format \;\ set -u window-status-current-style \;\ set -u window-status-current-format \;\ refresh-client -S bind -T root F4 kill-pane # new window and retain cwd and set default name to blank bind -T root F3 new-window -c "#{pane_current_path}" -n '' bind -T root F1 split-window -h -c "#{pane_current_path}" bind -T root F2 split-window -v -c "#{pane_current_path}"