Skip to content

Instantly share code, notes, and snippets.

@alexpw
Created June 16, 2022 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexpw/7d406734f912f835d705066de8286bda to your computer and use it in GitHub Desktop.
Save alexpw/7d406734f912f835d705066de8286bda to your computer and use it in GitHub Desktop.
set -g prefix `
bind ` send-prefix
# Use vi or emacs-style key bindings in the status line,
# for example at the command prompt. The default is emacs,
# unless the VISUAL or EDITOR environment variables are set
# and contain the string `vi'.
set -g status-keys vi
set-option -g default-shell /opt/homebrew/bin/fish
#set -g default-terminal "screen-256color"
set-option -sa terminal-overrides ',screen-256color:RGB'
set -g history-limit 10000
# Start numbering at 1
set -g base-index 1
# Allows for faster key repetition
set -sg escape-time 0
# Rather than constraining window size to the maximum size of any client
# connected to the *session*, constrain window size to the maximum size of any
# client connected to *that window*. Much more reasonable.
setw -g aggressive-resize on
# Allows us to use prefix + a <command> to send commands to a TMUX session inside
# another TMUX session
bind a send-prefix
# Activity monitoring
setw -g monitor-activity on
set -g visual-activity on
# Reload tmux config
bind r source-file ~/.tmux.conf
bind | split-window -h
bind - split-window -v
unbind l
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind T swap-window -t 1
bind-key J resize-pane -D 5
bind-key K resize-pane -U 5
bind-key H resize-pane -L 5
bind-key L resize-pane -R 5
set-window-option -g automatic-rename
set-option -g renumber-windows on
# from powerline
run-shell "tmux set-environment -g TMUX_VERSION_MAJOR $(tmux -V | cut -d' ' -f2 | cut -d'.' -f1 | sed 's/[^0-9]*//g')"
run-shell "tmux set-environment -g TMUX_VERSION_MINOR $(tmux -V | cut -d' ' -f2 | cut -d'.' -f2 | sed 's/[^0-9]*//g')"
# status bar
if-shell '\( #{$TMUX_VERSION_MAJOR} -eq 2 -a #{$TMUX_VERSION_MINOR} -lt 2\) -o #{$TMUX_VERSION_MAJOR} -le 1' 'set-option -g status-utf8 on'
# rm mouse mode fail
if-shell '\( #{$TMUX_VERSION_MAJOR} -eq 2 -a #{$TMUX_VERSION_MINOR} -ge 1\)' 'set -g mouse off'
if-shell '\( #{$TMUX_VERSION_MAJOR} -eq 2 -a #{$TMUX_VERSION_MINOR} -lt 1\) -o #{$TMUX_VERSION_MAJOR} -le 1' 'set -g mode-mouse off'
# fix pane_current_path on new window and splits
if-shell "test '#{$TMUX_VERSION_MAJOR} -gt 1 -o \( #{$TMUX_VERSION_MAJOR} -eq 1 -a #{$TMUX_VERSION_MINOR} -ge 8 \)'" 'unbind c; bind c new-window -c "#{pane_current_path}"'
if-shell "test '#{$TMUX_VERSION_MAJOR} -gt 1 -o \( #{$TMUX_VERSION_MAJOR} -eq 1 -a #{$TMUX_VERSION_MINOR} -ge 8 \)'" "unbind '\"'; bind '\"' split-window -v -c '#{pane_current_path}'"
if-shell "test '#{$TMUX_VERSION_MAJOR} -gt 1 -o \( #{$TMUX_VERSION_MAJOR} -eq 1 -a #{$TMUX_VERSION_MINOR} -ge 8 \)'" 'unbind v; bind v split-window -h -c "#{pane_current_path}"'
#if-shell "test '#{$TMUX_VERSION_MAJOR} -gt 1 -o \( #{$TMUX_VERSION_MAJOR} -eq 1 -a #{$TMUX_VERSION_MINOR} -ge 8 \)'" 'unbind %; bind % split-window -h -c "#{pane_current_path}"'
# Mouse
#set-option -g mouse on
# set -g focus-events on
# Clipboard
set-option -g default-command 'exec reattach-to-user-namespace -l /opt/homebrew/bin/fish'
setw -g mode-keys vi
bind Escape copy-mode
bind -Tcopy-mode-vi 'v' send -X begin-selection
bind -Tcopy-mode-vi 'C-v' send -X rectangle-toggle
bind -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
# status bar cfg
#set -g status-interval 1
#set -g status-justify centre # center align window list
#set -g status-left-length 20
#set -g status-right-length 140
#set -g status-left '#P #[fg=green]#H #[fg=black]• #[fg=green,bright]#(uname -r | cut -c 1-6)#[default]'
# set -g status-right '#[fg=green,bg=default,bright]#(tmux-mem-cpu-load) #[fg=red,dim,bg=default]#(uptime | cut -f 4-5 -d " " | cut -f 1 -d ",") #[fg=white,bg=default]%a%l:%M:%S %p#[default] #[fg=blue]%Y-%m-%d'
#set -g status-right "#[fg=blue]#S #I:#P #[fg=yellow]:: %d %b %Y #[fg=green]:: %l:%M %p :: #(date -u | awk '{print $4}')::"
# DRACULA status bar
# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, weather, time
set -g @dracula-show-flags on
set -g @dracula-show-location off
set -g @dracula-show-timezone off
set -g @dracula-military-time on
set -g @dracula-plugins "battery git weather time"
# THEME
# https://github.com/seebi/tmux-colors-solarized/blob/master/tmuxcolors-256.conf
# default statusbar colors
set-option -g status-style fg=colour136,bg=colour235 #yellow and base02
# default window title colors
set-window-option -g window-status-style fg=colour244,bg=default #base0 and default
#set-window-option -g window-status-style dim
# active window title colors
set-window-option -g window-status-current-style fg=colour166,bg=default #orange and default
#set-window-option -g window-status-current-style bright
# pane border
set-option -g pane-border-style fg=colour235 #base02
set-option -g pane-active-border-style fg=colour240 #base01
# message text
set-option -g message-style fg=colour166,bg=colour235 #orange and base02
# pane number display
set-option -g display-panes-active-colour colour33 #blue
set-option -g display-panes-colour colour166 #orange
# clock
set-window-option -g clock-mode-colour colour64 #green
# bell
set-window-option -g window-status-bell-style fg=colour235,bg=colour160 #base02, red
# TPM - PLUGIN MANAGER
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
#set -g @plugin 'christoomey/vim-tmux-navigator'
#set -g @plugin 'nhdaly/tmux-better-mouse-mode'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-save-interval '5'
set -g @continuum-restore 'on'
##set -g @plugin 'tmux-plugins/tmux-copycat'
##set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'dracula/tmux'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment