Skip to content

Instantly share code, notes, and snippets.

@dtanphat9388
Created September 11, 2025 11:20
Show Gist options
  • Select an option

  • Save dtanphat9388/41ab89b032d4f6adc6e8134c9440b7e8 to your computer and use it in GitHub Desktop.

Select an option

Save dtanphat9388/41ab89b032d4f6adc6e8134c9440b7e8 to your computer and use it in GitHub Desktop.
# ------------------------
# -- OPTIONS
# ------------------------
set -g mouse on
set -g base-index 1
set -gw pane-base-index 1
set -g mode-keys vi # default emacs
set -g display-panes-time 1500
set -gw automatic-rename off
set -g renumber-windows on
set -a terminal-features 'xterm-256color:RGB' # improve for nvim run in tmux
# -- opts required by nvim plugin 'image.nvim'
set -gq allow-passthrough on
set -g visual-activity off
unbind C-b
set -g prefix C-a
# ------------------------
# -- KEYBINDINGS
# ------------------------
# -- [ EXAMPLES ]
# -- example keybinding use with tmux_is_fowarded
# bind -n M-1 if-shell "$tmux_is_fowarded" "send-keys M-1" "select-window -t 1" # window: select window 1
forward_programs="view|n?vim?|fzf"
tmux_is_fowarded="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?($forward_programs)(diff)?$'"
tmux_is_vi_mode="#{==:#{env:ZVM_MODE},#{env:ZVM_MODE_NORMAL}}"
bind [ splitw -Z "tmux capture-pane -p -e -J -S - -E - -t - | nvim -c 'nnoremap <buffer> q :q! <CR>' -c 'set nomodifiable nonumber norelativenumber laststatus:0 ft=log' + -"
# bind [ splitw -Z "tmux capture-pane -p -e -J -S - -E - -t - | nvim +BaleiaColorize -c 'nnoremap <buffer> q :q! <CR>' -c 'set nomodifiable nonumber norelativenumber laststatus:0 ft=log' + -"
bind R source-file -F '#{config_files}'
display-message -F 'loaded #{config_files}' # tmux: reload config file
# -- navigation options
bind n split-window -h select-layout main-vertical # window: close window
bind l split-window -h
bind j split-window
bind N new-window -c '#{pane_current_path}' -n term # window: close window
bind -r ^j switch-client -n # sesson: select next session
bind -r ^k switch-client -p # sesson: select prev session
bind -r ^l select-window -n # window: select next window
bind -r ^h select-window -p # window: select prev window
bind -n ^h if-shell "$tmux_is_fowarded" "send-keys ^h" {select-pane -L}
bind -n ^j if-shell "$tmux_is_fowarded" "send-keys ^j" {select-pane -D}
bind -n ^k if-shell "$tmux_is_fowarded" "send-keys ^k" {select-pane -U}
bind -n ^l if-shell "$tmux_is_fowarded" "send-keys ^l" {select-pane -R}
bind -n ^^ if-shell "$tmux_is_fowarded" "send-keys C-^" last-pane # vim: goto Vim
## -- resize
bind -r H resize-pane -L 5 # pane: increase pane size left
bind -r J resize-pane -D 5 # pane: increase pane size down
bind -r K resize-pane -U 5 # pane: increase pane size up
bind -r L resize-pane -R 5 # pane: increase pane size right
bind m resize-pane -Z # pane: toggle maximum
bind \# if-shell "$tmux_is_fowarded" "send-keys #" display-pane
bind -n ^w if-shell "$tmux_is_fowarded" "send-keys C-w" kill-pane # vim: close pane or vim window
# ------------------------
# -- PLUGINS
# ------------------------
set -g @tpm_plugins '
tmux-plugins/tpm
tmux-plugins/tmux-sensible
dtanphat9388/tmux-theme
'
# 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 @resurrect-strategy-nvim 'session'
# set -g @continuum-restore 'on'
# set -g @plugin dtanphat9388/tmux-theme
set -g @tmux_theme_window_icon "
 (z|ba)?sh|term
 n?vim|code|tmux|book.*
 book|man(ual)?|docs?|cheat|notes?|man
󱃾 kube.*|k8s|helm(file)?
 ai|copilot
 tmp.*|temp.*
"
# -- [START] automatic install tmux plugin manager if not installed
# ------------------------------------------------------------------------------------------------------------------------
%hidden tmux_tpm_path='~/.tmux/plugins/tpm'
if-shell "test ! -d $tmux_tpm_path" \
"run 'git clone https://github.com/tmux-plugins/tpm $tmux_tpm_path && $tmux_tpm_path/bin/install_plugins'"
run -b "$tmux_tpm_path/tpm"
# -- [END]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment