Skip to content

Instantly share code, notes, and snippets.

@LintaoAmons
Created November 6, 2022 14:01
Show Gist options
  • Save LintaoAmons/b79d866e298c8d7e6744a021a73f21f7 to your computer and use it in GitHub Desktop.
Save LintaoAmons/b79d866e298c8d7e6744a021a73f21f7 to your computer and use it in GitHub Desktop.
My current tmux config
#-------------------------------------------------------#
#-------------------------------------------------------#
# General settings ⬇️ ⬇️ ⬇️
#-------------------------------------------------------#
#set mouse off/on - if off, forces you to use keyboard with prefix-[
set -g mouse on
# start with window 1 (instead of 0)
set -g base-index 1
# start with pane 1
set -g pane-base-index 1
# allow utf8 support
set -q -g status-utf8 on # expect UTF-8 (tmux < 2.2)
setw -q -g utf8 on
# Or for tmux >= 2.6
set -sg escape-time 10
#-------------------------------------------------------#
#-------------------------------------------------------#
# Styles ⬇️ ⬇️ ⬇️
#-------------------------------------------------------#
#256 colours
set -g default-terminal "screen-256color"
# Segguested by neovim healthcheck
set-option -sa terminal-overrides ',screen-256color:RGB'
set-option -sa terminal-overrides ',XXX:RGB'
# status bar
set -g status-style bg=default
set -g status-left ''
set -g status-left-length 90
set -g status-right ''
set -g status-right-length 90
set -g status-interval 0
set -g status-justify absolute-centre
# set inactive/active window(pane) styles
set -g window-style 'fg=colour247,bg=colour236'
set -g window-active-style 'fg=colour250,bg=black'
set -g status-interval 1
set -g window-status-format '#I:#(pwd="#{pane_current_path}"; echo ${pwd####*/})#F'
set -g window-status-current-format '#I:#(pwd="#{pane_current_path}"; echo ${pwd####*/})#F'
set -g pane-border-style fg='#78909C'
set -g pane-active-border-style fg='#FFD600'
# pane-border-style
# set-option -w pane-border-status off
#-------------------------------------------------------#
#-------------------------------------------------------#
# PANE NAVIGATION/MANAGEMENT ⬇️ ⬇️ ⬇️
#-------------------------------------------------------#
# splitting panes
# use vim-like keys for splits and windows
bind \\ split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# pane resizing
bind -r H resize-pane -L 2
bind -r J resize-pane -D 2
bind -r K resize-pane -U 2
bind -r L resize-pane -R 2
# default pane layouts
bind + select-layout main-horizontal
bind = select-layout main-vertical
# Rotate panes
bind -r o rotate-window
# ====================== My configs
# set history
set -g history-limit 10000 # boost history
set -g history-file ~/.cache/zsh/history
# Enable native Mac OS X copy/paste
set-option -g default-command "/bin/bash -c 'which reattach-to-user-namespace >/dev/null && exec reattach-to-user-namespace $SHELL -l || exec $SHELL -l'"
#-------------------------------------------------------#
#-------------------------------------------------------#
# TMUX-RESURRECT ⬇️ ⬇️ ⬇️
#-------------------------------------------------------#
run-shell ~/build/tmux/tmux-resurrect/resurrect.tmux
set -g @resurrect-capture-pane-contents 'on'
# change defaults for resurrect (two steps)
# 1. unbind the current defaults C-s and C-r
unbind -T prefix C-s
unbind -T prefix C-r
#2. Still use prefix C-s and C-r, but now ask for (y/n) response before saving/restoring.
#This assumes tmux-resurrect is saved to ~/build/tmux/tmux-resurrect folder
bind -T prefix C-s confirm-before -p 'Save this tmux session? (y/n)' 'run-shell ~/build/tmux/tmux-resurrect/scripts/save.sh'
bind -T prefix C-r confirm-before -p 'Resurrect last tmux session? (y/n)' 'run-shell ~/build/tmux/tmux-resurrect/scripts/restore.sh'
#-------------------------------------------------------#
#-------------------------------------------------------#
# Vim mode ⬇️ ⬇️ ⬇️
#-------------------------------------------------------#
# use vi mode
setw -g mode-keys vi
set -g status-keys vi
# bind
bind [ copy-mode
# Setup 'v' to begin selection as in Vim
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
unbind -T copy-mode-vi Enter
bind -T copy-mode-vi Enter send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
#-------------------------------------------------------#
#-------------------------------------------------------#
# Shortcuts ⬇️ ⬇️ ⬇️
#-------------------------------------------------------#
bind r source-file ~/.tmux.conf \; display "Reloaded ~/.tmux.conf"
bind d send-keys -R C-l \; clear-history
bind x kill-pane
# bind-key -n M-3 run-shell 'toggle-tmux-popup'
# Quickly open a scratch pad in a popup window with Alt-Shift-T
bind-key -n -N 'Open a scratch session in a popup window' M-3 {
display-popup -E -w 60% 'tmux attach-session -t scratch 2>/dev/null || tmux new-session -s scratch -c "#{pane_current_path}"'
}
bind-key -n "M-8" run-shell -b "~/.tmux/plugins/tmux-fzf/scripts/pane.sh switch"
#-------------------------------------------------------#
#-------------------------------------------------------#
# NVim Requirement ⬇️ ⬇️ ⬇️
#-------------------------------------------------------#
set-option -g focus-events on
########################## 🔽 TPM 🔽 ###########################
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'sainnhe/tmux-fzf'
TMUX_FZF_OPTIONS="-p -w 80% -h 76% -m"
TMUX_FZF_LAUNCH_KEY="f"
lMUX_FZF_ORDER="session|pane|command|keybinding|window"
TMUX_FZF_PANE_FORMAT="#{p15:#{b:pane_current_path}} :: #{pane_current_command}"
# press prefix-I after add/delete plugin
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
########################## 🔼 TPM 🔼 ##########################
########################## 🔽 GRUVBOX DARK 🔽 ###########################
set-option -g status-interval 3
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{b:pane_current_path} :: #{b:pane_current_command}'
## COLORSCHEME: gruvbox dark (medium)
set-option -g status "on"
# default statusbar color
set-option -g status-style bg=colour237,fg=colour223 # bg=bg1, fg=fg1
# default window title colors
set-window-option -g window-status-style bg=colour214,fg=colour237 # bg=yellow, fg=bg1
# default window with an activity alert
set-window-option -g window-status-activity-style bg=colour237,fg=colour248 # bg=bg1, fg=fg3
# active window title colors
set-window-option -g window-status-current-style bg=red,fg=colour237 # fg=bg1
# pane border
set-option -g pane-active-border-style fg=colour250 #fg2
set-option -g pane-border-style fg=colour237 #bg1
# message infos
set-option -g message-style bg=colour239,fg=colour223 # bg=bg2, fg=fg1
# writing commands inactive
set-option -g message-command-style bg=colour239,fg=colour223 # bg=fg3, fg=bg1
# pane number display
set-option -g display-panes-active-colour colour250 #fg2
set-option -g display-panes-colour colour237 #bg1
# clock
set-window-option -g clock-mode-colour colour109 #blue
# bell
set-window-option -g window-status-bell-style bg=colour167,fg=colour235 # bg=red, fg=bg
## Theme settings mixed with colors (unfortunately, but there is no cleaner way)
set-option -g status-justify "left"
set-option -g status-left-style none
set-option -g status-left-length "80"
set-option -g status-right-style none
set-option -g status-right-length "80"
set-window-option -g window-status-separator ""
set-option -g status-left "#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]"
set-option -g status-right "#[bg=colour237,fg=colour239 nobold, nounderscore, noitalics]#[bg=colour239,fg=colour246] %Y-%m-%d  %H:%M #[bg=colour239,fg=colour248,nobold,noitalics,nounderscore]#[bg=colour248,fg=colour237] #h "
set-window-option -g window-status-current-format "#[bg=colour214,fg=colour237,nobold,noitalics,nounderscore]#[bg=colour214,fg=colour239] #I #[bg=colour214,fg=colour239,bold] #{b:pane_current_path}#{?window_zoomed_flag,*Z,} :: #{pane_current_command} #[bg=colour237,fg=colour214,nobold,noitalics,nounderscore]"
set-window-option -g window-status-format "#[bg=colour239,fg=colour237,noitalics]#[bg=colour239,fg=colour223] #I #[bg=colour239,fg=colour223] #{b:pane_current_path} #[bg=colour237,fg=colour239,noitalics]"
########################## 🔼 GRUVBOX DARK 🔼 ##########################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment