Skip to content

Instantly share code, notes, and snippets.

@andynu
Created February 24, 2025 20:43
Show Gist options
  • Save andynu/5d52ebf85db16c9bebfd15336d4ecc0b to your computer and use it in GitHub Desktop.
Save andynu/5d52ebf85db16c9bebfd15336d4ecc0b to your computer and use it in GitHub Desktop.
tmux.conf
set -s escape-time 1
set -g base-index 1
setw -g pane-base-index 1
# un-do default
unbind C-b
unbind C-d
# powerline
set-option -g status on
set-option -g status-interval 2
#set-option -g status-utf8 on
set-option -g status-justify "centre"
set-option -g status-left-length 60
set-option -g status-right-length 90
#set-option -g status-left "#(~/.dot/app/tmux/plugins/tmux-powerline/powerline.sh left)"
#set-option -g status-right "#(~/.dot/app/tmux/plugins/tmux-powerline/powerline.sh right)"
#set-window-option -g window-status-current-format "#[fg=colour235, bg=colour27]⮀#[fg=colour255, bg=colour27] #I ⮁ #W #[fg=colour27, bg=colour235]⮀"
# tmux particulars
#set -g status-keys vi
setw -g mode-keys vi
#setw -g utf8 on
set-option -g set-titles on
set-option -g set-titles-string '#S:#I.#P #W' # window number,program name,active (or not)
bind r source-file ~/.tmux.conf
#set -g set-remain-on-exit off
set -g history-limit 10000
setw -g automatic-rename off
set-option -g focus-events on
# colors
#set -g pane-active-border-fg blue
#set -g pane-active-border-bg colour232
#setw -g window-status-current-bg colour237
#setw -g window-status-current-fg colour11
#setw -g window-status-current-attr bright
#setw -g window-status-attr dim
#setw -g window-status-bg colour232
#set -g status-attr default
#set -g status-bg default
#set -g status-fg white
set -g status-left '#[fg=default](#S)#[default]'
set -g status-right '#[fg=colour236]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=colour249]%H:%M#[default]'
# window status
setw -g window-status-format " #F#I:#W#F "
setw -g window-status-current-format " #F#I:#W#F "
setw -g window-status-format "#[bg=black]#[fg=colour238] #I #[bg=colour244]#[fg=colour238] #W "
setw -g window-status-current-format "#[bg=black]#[fg=colour244] #I #[fg=colour244]#[bg=colour15] #W "
#setw -g window-status-current-bg colour0
#setw -g window-status-current-fg colour11
#setw -g window-status-current-attr dim
#setw -g window-status-bg green
#setw -g window-status-fg black
#setw -g window-status-attr reverse
#setw -g window-status-alert-attr default
#setw -g window-status-alert-fg default
#setw -g window-status-alert-bg colour11
# THEME
set -g message-style bg='#333333',fg='#999999'
set -g status-style bg='#333333',fg='#999999'
set -g status-interval 1
#
unbind %
bind _ split-window
bind S split-window
bind | split-window -h
bind V split-window -h
bind v split-window -h
bind L swap-pane -D
bind H swap-pane -U
bind K kill-session
# mimic screen
set -g prefix C-a
bind a send-prefix
bind C-a last-window
bind m setw monitor-activity
setw -g monitor-activity on
unbind ,
bind A command-prompt "rename-window %%"
unbind [
bind Escape copy-mode
# move tmux copy buffer into x clipboard
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
unbind '"'
bind '"' choose-window
unbind h
unbind l
bind -r h select-pane -L\; refresh-client -S
bind -r j select-pane -D\; refresh-client -S
bind -r k select-pane -U\; refresh-client -S
bind -r l select-pane -R\; refresh-client -S
bind C-h select-pane -L
bind C-j select-pane -D
bind C-k select-pane -U
bind C-l select-pane -R
#unbind M-0
#unbind M-1
#unbind M-2
#unbind M-3
#unbind M-4
#unbind M-5
bind b break-pane
bind M-q join-pane -t :1
bind M-w join-pane -t :2
bind M-e join-pane -t :3
bind M-r join-pane -t :4
bind M-t join-pane -t :5
bind M-y join-pane -t :6
bind M-u join-pane -t :7
bind M-u join-pane -t :8
bind M-o join-pane -t :9
bind M-p join-pane -t :0
bind N neww \; splitw -d
unbind o
bind o select-layout "active-only"
# bind -r C-j swap-pane -D
# bind -r C-k swap-pane -U
# bind -r C-n next-window
# bind -r C-p previous-window
#bind O select-layout "main-vertical"
#bind q kill-pane
#bind Q kill-window
#bind q switchc -t0
#bind -r C-k rotate-window -U
##bind -r C-j rotate-window -D
#bind -r j down-pane
#bind -r k up-pane
#bind -r - resize-pane -D 3
#bind -r = resize-pane -U 3
#bind -r y next-layout
#bind s split-window
#bind Tab up-pane
#bind u setw force-width 0
#bind w switchc -t1
#bind y setw force-width 81
#set -g display-time 2000
#set -g message-attr bright
#set -g message-bg colour233
#set -g message-fg white
#set -g mouse-select-pane on
#
#set-option -g bell-action none
##set-option -g default-terminal "screen-256color"
#set -g default-terminal "xterm-256color"
#set -g default-terminal "tmux-256color"
# tell Tmux that outside terminal supports true color
# set -sga terminal-overrides ",xterm-256color:Tc"
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",xterm-256color:Tc"
#setw -g xterm-keys on
#bind C-o last-window
#bind D detach \; lock
#bind e switchc -t2
#bind i choose-window
bind C-r refresh-client
#bind q kill-pane
##CLIPBOARD selection integration
##Requires prefix key before the command key
#Copy tmux paste buffer to CLIPBOARD
#bind C-c run "tmux show-buffer | xclip -i -selection clipboard"
#Copy CLIPBOARD to tmux paste buffer and paste tmux paste buffer
#bind C-v run "tmux set-buffer \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"
# 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?|fzf)(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'"
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
set -g mouse off
# Mouse selection copy
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe "xclip -in -selection primary -f | xclip -in -selection clipboard"
# Keyboard selection copy
bind-key -T copy-mode-vi y send-keys -X copy-pipe "xclip -in -selection primary -f | xclip -in -selection clipboard"
# vim: ft=tmux:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment