- mode-style bg=yellow,fg=black (black on a dark terminal was invisible) - MouseDragEnd1Pane copies (pbcopy on macOS, tmux buffer elsewhere) without leaving copy-mode
272 lines
12 KiB
Bash
272 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='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
|
|
# is_vim Note: {{{
|
|
# The pane's foreground command, as tmux sees it. The older variant read a
|
|
# "@tmux_vim_<pane>" variable that a vim plugin had to set; nothing sets it
|
|
# here, so C-h/j/k/l never reached vim.
|
|
# }}}
|
|
|
|
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) {{{
|
|
# stock binding = "release the drag: copy AND leave copy-mode", which loses
|
|
# the selection on screen. Rebound below (clipboard section) as copy without
|
|
# leaving, so a drag is enough and y stays available.
|
|
# ref: https://github.com/tmux/tmux/issues/140
|
|
# }}}
|
|
|
|
set -g prefix C-a # bind screen like prefix
|
|
bind C-a send-prefix # C-a C-a = literal C-a (shell home)
|
|
|
|
# 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 (same arrow layout as the moves below, with prefix)
|
|
bind-key -r C-u resize-pane -U 5
|
|
bind-key -r C-h resize-pane -L 5
|
|
bind-key -r C-j resize-pane -D 5
|
|
bind-key -r C-k resize-pane -R 5
|
|
bind-key -r C-n next-window \; set status on
|
|
bind-key -r C-p previous-window \; set status on
|
|
|
|
# Moving across panes (and vim), no prefix: ctrl + u/h/j/k laid out as arrows
|
|
# (u up, h left, j down, k right). These keys sit at the same place on AZERTY
|
|
# and QWERTY US, and need no option key. Each one still reaches vim when vim
|
|
# runs in the pane. C-l is free, so it clears the shell screen again.
|
|
# Shell cost: C-u (readline "clear the line") is taken.
|
|
bind -n C-u if-shell "$is_vim" "send-keys C-u" "select-pane -U"
|
|
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 -R"
|
|
|
|
bind Escape copy-mode # bind vi-like 'normal' mode
|
|
bind -Tcopy-mode-vi 'v' send -X begin-selection # bind vi-like visual mode
|
|
# Clipboard: pbcopy/pbpaste on macOS. Elsewhere tmux's own buffer, which tmux
|
|
# also hands to the terminal through OSC 52 (set-clipboard), so it reaches the
|
|
# local clipboard over ssh. xsel/xclip dropped: headless servers have no X.
|
|
# Releasing a mouse drag copies too (selection kept on screen, copy-mode stays).
|
|
if-shell 'command -v pbcopy >/dev/null' \
|
|
'bind -Tcopy-mode-vi y send -X copy-pipe-and-cancel pbcopy ; bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-pipe-no-clear pbcopy ; bind p run "pbpaste | tmux load-buffer - ; tmux paste-buffer"' \
|
|
'bind -Tcopy-mode-vi y send -X copy-selection-and-cancel ; bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-selection-no-clear ; bind p 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-key i "split-window -h -c '#{pane_current_path}'" # i: side by side (vertical bar)
|
|
bind-key - "split-window -v -c '#{pane_current_path}'" # -: stacked (horizontal bar)
|
|
|
|
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=yellow,fg=black # selection: same accent as the status bar
|
|
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'
|
|
|