Skip to content

Instantly share code, notes, and snippets.

@nycksw
Last active November 27, 2025 14:35
Show Gist options
  • Select an option

  • Save nycksw/6d8af2a24ece01f880683638e4a68554 to your computer and use it in GitHub Desktop.

Select an option

Save nycksw/6d8af2a24ece01f880683638e4a68554 to your computer and use it in GitHub Desktop.
tmux.conf
unbind -a # No defaults; all keybindings are explicit.
bind : command-prompt
bind ? list-keys
bind C customize-mode -Z
bind \$ command-prompt -I "#S" { rename-session "%%" }
bind \~ show-messages
bind a send-prefix # For sending a literal ^a.
bind i display-message
bind r source-file ~/.tmux.conf \;\; display-message "Configuration reloaded."
bind s choose-tree -Zs
set -as terminal-features ",xterm-256color:RGB"
set -g default-terminal "tmux-256color"
set -g escape-time 0 # Disable the delay for function/meta-key sequences.
set -g history-limit 32768
set -g mouse off
set -g prefix ^a
set -g status-keys vi
bind c new-window
bind n next-window
bind p previous-window
bind ^A last-window
bind A command-prompt "rename-window %%"
bind k confirm-before "kill-window"
set -g renumber-windows on
bind 0 select-window -t :=0
bind 1 select-window -t :=1
bind 2 select-window -t :=2
bind 3 select-window -t :=3
bind 4 select-window -t :=4
bind 5 select-window -t :=5
bind 6 select-window -t :=6
bind 7 select-window -t :=7
bind 8 select-window -t :=8
bind 9 select-window -t :=9
bind v split-window # Split window (v)ertically.
bind b split-window -h # Split window (b)orizontally :)
bind f command-prompt { find-window -Z "%%" }
bind d detach-client
bind * list-clients
bind ) switch-client -n
bind ( switch-client -p
bind D choose-client -Z
bind L switch-client -l
bind C-z suspend-client
bind C-l refresh-client \; display-message "Client refreshed."
bind j command-prompt -p "Join pane from:" "join-pane -s '%%'"
bind \! break-pane
bind x confirm-before "kill-pane"
bind \; last-pane
bind z resize-pane -Z
# Set a (m)onitor for 30 seconds of silence; useful for indicating that a
# long-running command has finished.
bind m {
setw monitor-silence 30
display-message "30-second silence monitor set."
setw focus-events on
set-hook -g pane-focus-in 'setw monitor-silence 0'
}
# Cycle through layouts.
bind -n C-Space next-layout
bind -n C-o rotate-window
bind \{ swap-pane -U
bind \} swap-pane -D
bind -n M-h select-pane -L # Move to the pane on the left.
bind -n M-j select-pane -D # Move to the pane below.
bind -n M-k select-pane -U # Move to the pane above.
bind -n M-l select-pane -R # Move to the pane on the right.
bind -n M-H resize-pane -L 5 # Alt+Shift+h to resize pane left.
bind -n M-J resize-pane -D 5 # Alt+Shift+j to resize pane down.
bind -n M-K resize-pane -U 5 # Alt+Shift+k to resize pane up.
bind -n M-L resize-pane -R 5 # Alt+Shift+l to resize pane right.
set -g set-titles on
set -g set-titles-string "#T #W"
set-window-option -g automatic-rename on
set -g monitor-activity on # Visual indicator for activity in a pane,
set -g visual-activity off # but don't put a long message on the status line.
set -g pane-border-indicators arrows
set -g pane-border-lines single
# Kluge to disable borders if there's only one pane.
set -g @border_update 'if-shell -F "#{==:#{window_panes},1}" \
"set -w pane-border-status off; \
set -w pane-border-style bg=default,fg=default; \
set -w pane-active-border-style bg=default,fg=default; \
refresh-client -S" \
"set -w pane-border-status top; \
set -w pane-border-style fg=colour22; \
set -w pane-active-border-style fg=colour46; \
refresh-client -S"'
set-hook -g after-new-window "run -C \"#{@border_update}\""
set-hook -g window-layout-changed "run -C \"#{@border_update}\""
set -g message-style bg=black,fg=colour46,bright
set-window-option -g mode-style bg=black,fg=yellow
set -g status-style fg=black,bg=black,bright
set -g status-interval 5
set -g status-justify right
set-window-option -g window-status-format '#I/#W'
set-window-option -g window-status-current-format '#I/#W'
set-window-option -g window-status-style fg=colour22,bg=black
set-window-option -g window-status-current-style fg=colour46,bg=black
set -g status on
set -g status-justify left
set -g status-left-length 35
# Color indicator for hosts that are directly exposed to the dirty Internet.
if-shell "test -f ~/.exposed" {
set-environment -g fg "white"
set-environment -g bg "colour52"
} {
# Otherwise, just green on black.
set-environment -g fg colour46
set-environment -g bg "black"
}
set -g status-left '#[fg=#{fg},bg=#{bg}] #(hostname -s)/#[fg=white]#S#[default] '
set -g status-right-length 60
set -g status-right '#[fg=lightgray,nobold,bg=black] #[fg=lightgray,nobold]#(~/bin/tun_ip) #(TZ=America/Costa_Rica date +"%%Y%m%%d %%H:%M %%Z %%z")'
bind Escape copy-mode
# vi-style buffer nav and copy/paste.
set-window-option -g mode-keys vi
# Always let tmux sync with the system clipboard when it knows how.
set -g set-clipboard on # tmux v3.2+
# Decide once which copy command to use and store it in @copy_cmd.
if-shell -b 'command -v wl-copy >/dev/null' \
"set -g @copy_cmd 'wl-copy'" \
"if-shell -b 'command -v xclip >/dev/null' \
\"set -g @copy_cmd 'xclip -selection clipboard'\" \
\"set -g @copy_cmd 'pbcopy'\""
# Similarly, set paste command in @paste_cmd.
if-shell -b 'command -v wl-paste >/dev/null' \
"set -g @paste_cmd 'wl-paste'" \
"if-shell -b 'command -v xclip >/dev/null' \
\"set -g @paste_cmd 'xclip -o -selection clipboard'\" \
\"set -g @paste_cmd 'pbpaste'\""
# (y)ank selection to system clipboard, trimming trailing whitespace.
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "sed 's/[ \t]*\$//' | #{@copy_cmd}"
# Begin selection with v or mouse drag.
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi MouseDrag1Pane send -X begin-selection
# Paste from system clipboard with ] (loads into tmux buffer first).
bind ] run-shell "#{@paste_cmd} | tmux load-buffer - ; tmux paste-buffer"
# Navigation and cancel keys unchanged.
bind -T copy-mode-vi Enter send -X cursor-down
bind -T copy-mode-vi C-j send -X cursor-down
bind -T copy-mode-vi Escape send -X cancel
bind -T copy-mode-vi q send -X cancel
bind -T copy-mode-vi C-c send -X cancel
### Copy buffer keybindings. ###
bind -T copy-mode-vi h send-keys -X cursor-left
bind -T copy-mode-vi j send-keys -X cursor-down
bind -T copy-mode-vi k send-keys -X cursor-up
bind -T copy-mode-vi l send-keys -X cursor-right
bind -T copy-mode-vi C-f send-keys -X page-down
bind -T copy-mode-vi C-b send-keys -X page-up
bind -T copy-mode-vi n send-keys -X search-again
bind -T copy-mode-vi N send-keys -X search-reverse
bind -T copy-mode-vi ^ send-keys -X back-to-indentation
bind -T copy-mode-vi L send-keys -X bottom-line
bind -T copy-mode-vi \$ send-keys -X end-of-line
bind -T copy-mode-vi G send-keys -X history-bottom
bind -T copy-mode-vi g send-keys -X history-top
bind -T copy-mode-vi M send-keys -X middle-line
bind -T copy-mode-vi \% send-keys -X next-matching-bracket
bind -T copy-mode-vi \} send-keys -X next-paragraph
bind -T copy-mode-vi W send-keys -X next-space
bind -T copy-mode-vi E send-keys -X next-space-end
bind -T copy-mode-vi w send-keys -X next-word
bind -T copy-mode-vi e send-keys -X next-word-end
bind -T copy-mode-vi \{ send-keys -X previous-paragraph
bind -T copy-mode-vi B send-keys -X previous-space
bind -T copy-mode-vi b send-keys -X previous-word
bind -T copy-mode-vi 0 send-keys -X start-of-line
bind -T copy-mode-vi H send-keys -X top-line
bind -T copy-mode-vi WheelDownPane select-pane \; send-keys -X -N 5 scroll-down
bind -T copy-mode-vi WheelUpPane select-pane \; send-keys -X -N 5 scroll-up
bind -T copy-mode-vi Space send-keys -X begin-selection
bind -T copy-mode-vi V send-keys -X select-line
bind -T copy-mode-vi / command-prompt -T search -p "(search down)" { send-keys -X search-forward "%%" }
bind -T copy-mode-vi ? command-prompt -T search -p "(search up)" { send-keys -X search-backward "%%" }
bind -T copy-mode-vi : command-prompt -p "(goto line)" { send-keys -X goto-line "%%" }
### End of copy buffer keybindings. ###
if-shell "[ -f ~/.tmux/menus.conf ]" "source-file ~/.tmux/menus.conf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment