Files
config/tmux.conf
T
bchanot 825abe842a feat(macos): deploy tmux.conf + tpm plugins; cloudpex becomes an install-time offer
- tmux.conf (vi keys, C-a prefix, resurrect/continuum, window-name) → ~/.config/tmux/tmux.conf
  on macOS; tpm cloned, plugins fetched headlessly, libtmux installed non-fatally
- bashrc-osx / zshrc-osx export XDG_CACHE_HOME (session save dir of the config)
- Linux: install_cloudpex → offer_cloudpex ([y/N] with the /tmp and SSH offers)
- README + CLAUDE.md updated
2026-10-06 12:27:22 +02:00

269 lines
12 KiB
Bash

# --------------------------------------------------------------------------- #
# #
# Module: tmux.conf By: sohorx <banlin.adrien@gmail.com> #
# #
# Created: 2015/04/01 18:17:25 Updated: 2016/04/01 18:17:25 #
# #
# --------------------------------------------------------------------------- #
# Note: {{{ #
# minimalist tmux configuration which behave a bit like vi #
# }}} #
# --------------------------------------------------------------------------- #
# Global options: {{{
# --------------
set -g bell-action none # make it Shut up!
set-option -g default-shell $SHELL # set shell
set -g default-terminal "screen-256color" # term colors
#set -ga terminal-overrides ",*256col*:Tc" # term cap only
set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q,*256col*:Tc' # cursor control
setw -g mode-keys vi # vi mode
set -s escape-time 1 # Fix terminal name issues
set -g set-titles on # Turn on window titles
setw -g automatic-rename on # Automatically set window title
set -g mouse on # mouse cap
set-window-option -g clock-mode-colour brightwhite # set colour clock
set -g focus-events on # for vim (?)
set-option -g automatic-rename on # auto rename session
set-option -g status-interval 5 # rename session interval
set -g status on # enable status bar at start
# https://github.com/3rd/image.nvim/?tab=readme-ov-file#tmux
set -gq allow-passthrough on # image.nvim requirements
set -g visual-activity off # image.nvim requirements
# ------------------------------------------------------------------------- }}}
# Change default strings: {{{
# ----------------------
# Set window title string
set -g set-titles-string '#S :: #W :: #F#P #{pane_current_command}'
#set-option -g automatic-rename-format "#{b:pane_current_path}"
# ------------------------------------------------------------------------- }}}
# Variables: {{{
# ---------
is_vim='tmux show -v "@tmux_vim_#{pane_id}" | grep yes' # check if is vim
# is_vim Note: {{{
# vim is actually changing values of a variable to make it visible by tmux.
# Without this, tmux would have to grep the current pane to see what is
# running. ex:
# echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"
# }}}
resurrect_root_dir="$XDG_CACHE_HOME/tmux/resurect"
# chunk of status bar variables and coloration
#sep_st='#[fg=brightwhite,bg=brightblue]'
#sep_c='#[fg=black]'
#
#sep_d='#[fg=brightwhite,bold]'
#sep_e='#[default,fg=brightblack]#[bg=brightblack]#[fg=brightwhite]'
#sep_f='#[fg=black]'
#
#sep_g='#[fg=blue,bold]'
#sep_h='#[default,fg=brightwhite]#[fg=blue,bg=brightwhite,bold]'
#sep_i='#[default,bg=brightwhite,fg=black]'
#
#sep_b='#[fg=brightyellow]#[default, bg=brightyellow, fg=black]'
#sep_a='#[fg=yellow]#[bg=yellow, fg=black]'
#
#sep_off="#[fg=brightred]#[bg=brightred, fg=brightwhite, bold] OFF"
#sep_on="#[fg=green]#[bg=green, fg=brightwhite, bold] ON"
#
#brightwhite_fg="#[fg=brightwhite]"
##
sep_st='#[fg=brightwhite,bg=brightblue]'
sep_c='#[fg=black] '
sep_d='#[fg=brightwhite,bold] '
sep_e='#[default,fg=brightblack] #[bg=brightblack]#[fg=brightwhite]'
sep_f='#[fg=black]'
sep_g='#[fg=brightblue,bold] '
sep_h='#[default,fg=brightwhite] #[fg=black,bg=brightwhite,bold]'
sep_i='#[default,bg=brightwhite,fg=black]'
sep_b='#[fg=brightyellow] #[default, bg=brightyellow, fg=black]'
sep_a='#[fg=yellow] #[bg=yellow, fg=black]'
sep_off="#[fg=brightred] #[bg=brightred, fg=brightwhite, bold] OFF"
sep_on="#[fg=green]#[bg=green, fg=brightwhite, bold] ON"
brightwhite_fg="#[fg=brightwhite]"
# ------------------------------------------------------------------------- }}}
# Key bindings: {{{
# ------------
# Unbindings
unbind [
unbind C-b # (prefix)
unbind C-n # (nav)
unbind l
unbind C-p
unbind v # (selection)
unbind y # (copy)
unbind p # (pasting)
unbind % # (sp)
unbind '"' # (vs)
unbind-key -T copy-mode-vi MouseDragEnd1Pane # (mouse setting) {{{
# disable "release mouse drag to copy and exit copy-mode"
# ref: https://github.com/tmux/tmux/issues/140
# }}}
set -g prefix C-a # bind screen like prefix
# specific commands
bind-key C-o command-prompt "new-session -s %1 -c ~"
bind R source-file ~/.config/tmux/tmux.conf \; display-message "Config reloaded..."
# Resizing key bindings
bind-key -r C-l resize-pane -R 5
bind-key -r C-k resize-pane -U 5
bind-key -r C-j resize-pane -D 5
bind-key -r C-h resize-pane -L 5
bind-key -r C-n next-window \; set status on
bind-key -r C-p previous-window \; set status on
# Moving accross pane (and vim)
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
#bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
bind Escape copy-mode # bind vi-like 'normal' mode
bind -Tcopy-mode-vi 'v' send -X begin-selection # bind vi-like visual mode
bind -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "xsel -b -i" # xsel copy
bind p run "xsel -b -o | tmux load-buffer - ; tmux paste-buffer" # xsel paste
# bind vi-like copy/paste through 'normal' mode, (Note) {{{
# It is encouraged to use xsel instead of xclip, because xclip does not close
# STDOUT after it has read from tmux's buffer. As such, tmux doesn't know
# that the copy task has completed, and continues to wait for xclip's
# termination, thereby rendering tmux unresponsive.
# Here an example of copy paste with pbcopy/pbpaste (macos)
# bind -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "pbcopy"
# bind p run "pbpaste | tmux load-buffer - ; tmux paste-buffer"
# }}}
bind-key -Tcopy-mode-vi Escape send -X cancel # cancel v mode
bind-key -Tcopy-mode-vi ^v send -X rectangle-toggle # cancel v mode
bind-key -T copy-mode-vi MouseDown1Pane select-pane\; send-keys -X clear-selection
bind -n MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= \"#{pane_in_mode}\" \"copy-mode -eM\" \"send-keys -M\"' 'copy-mode -eM'
# (note) {{{
# The `bind-key -T copy-m...` let a single click do selection clearing for us.
# The `bind -n MouseDrag1Pane if -Ft= ...` changes the default binding of
# MouseDrag1Pane, the only difference is that we use `copy-mode -eM` instead
# of `copy-mode -M`, so that WheelDownPane can trigger copy-mode to exit when
# copy-mode is entered by MouseDrag1Pane
# }}}
bind-key k "split-window -v -b -c '#{pane_current_path}'"
bind-key h "split-window -h -b -c '#{pane_current_path}'"
bind-key j "split-window -v -c '#{pane_current_path}'"
bind-key l "split-window -h -c '#{pane_current_path}'"
bind q kill-window # Kill window
bind Q kill-session # Kill the session (not server)
bind C-c neww \; set status on # enable status bar
bind c neww \; set status on # disable status bar
# Enable disable bindings and change status bar with it {{{
bind -T root F10 set status off
bind -T root F9 set status on
bind -T root F12 \
set prefix None \; \
set key-table off \;\
set focus-events off \; \
set status-right '#{brightwhite_fg} #h #{sep_b} %a %d/%m/%Y #{sep_a} %H:%M #{sep_off} : #{continuum_status} ' \;\
set status on\; \
refresh-client -S\;
bind -T off F11 \
set -u prefix \;\
set -u key-table \;\
set -u focus-events \;\
set status-right '#{brightwhite_fg} #h #{sep_b} %a %d/%m/%Y #{sep_a} %H:%M #{sep_on} : #{continuum_status} ' \;\
set status on\;\
refresh-client -S\;
# }}}
# ------------------------------------------------------------------------- }}}
# Plugins: {{{
# -------
# To make plugins works, the run tpm must be done by the main file.
#
# run '~/.config/tmux/plugins/tpm/tpm'
##
set -g @tpm_plugins ' \
tmux-plugins/tpm \
ofirgall/tmux-window-name \
tmux-plugins/tmux-sensible \
tmux-plugins/tmux-resurrect \
tmux-plugins/tmux-continuum \
'
# plugins options
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-capture-pane-contents 'on'
set -g @resurrect-processes ' \
irb \
ipython \
~ranger \
pry \
ri \
"~bundle exec ri" \
"~bundle exec pry" \
"~pipenv shell" \
"~pipenv run" \
glow \
"~vaas-infra ssh" \
"~vaas-cli -s vaas-infra.dev.alphalink.fr ssh" \
ssh \
mosh \
tig \
'
set -g @resurrect-strategy-session 'always'
set -g @continuum-restore 'on'
set -g @continuum-save-interval '15' # save every minutes
set -g @resurrect-dir "$XDG_CACHE_HOME/tmux/$TMUX_SOCKET_NAME"
# ------------------------------------------------------------------------- }}}
# Status Bar: {{{
# ----------
set -wg mode-style bg=black,fg=brightwhite
set-window-option -g window-status-separator ''
set -g status-position bottom
set -g status-left-length 42
set -g status-right-length 80
set -g status-justify left
#setw -g status-style bg=black
setw -g status-style bg=default
set -g status-left '#{sep_st} λ #S #{sep_c}'
# setw -g window-status-format '#{sep_d} #I #{sep_e} #W #{sep_f}'
# setw -g window-status-current-format '#{sep_g} #I #{sep_h} #W #{sep_i}'
# set -g status-right '#{brightwhite_fg} #h #{sep_b} %a %d/%m/%Y #{sep_a} %H:%M #{sep_on} : #{continuum_status} '
setw -g window-status-format '#{sep_e} #W #{sep_f}'
setw -g window-status-current-format '#{sep_h} #W #{sep_i}'
set -g status-right '#{sep_b} #h #{sep_e}#{sep_on} : #{continuum_status} '
# set Panel borders
set -g pane-active-border-style fg=white,bg=white
set -g pane-border-style fg=white,bg=default
# set Message text
set-option -g message-style bg=default,fg=red
set-option -g message-command-style bg=default,fg=brightwhite
# ------------------------------------------------------------------------- }}}
run '~/.config/tmux/plugins/tpm/tpm'