dotfiles/dot_tmux.conf.tmpl

155 lines
5.4 KiB
Cheetah

# Core options (https://github.com/tmux-plugins/tmux-sensible)
#
# address vim mode switching delay (http://superuser.com/a/252717/65504)
set -s escape-time 50
# increase scrollback buffer size
set -g history-limit 50000
# tmux messages are displayed for 4 seconds
set -g display-time 4000
# screen-256 true color
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",xterm-256color:Tc"
# focus events enabled for terminals that support them
set -g focus-events on
# super useful when using "grouped sessions" and multi-monitor setup
setw -g aggressive-resize on
# ===========================================================================
# Other options
set -q -g status-utf8 on # expect UTF-8 (tmux lower than 2.2)
setw -q -g utf8 on
set -g status on
# refresh 'status-left' and 'status-right' more often
set -g status-interval 5
set -g status-justify left
set -g status-position bottom
set -g status-keys vi
# C-b is not acceptable -- Vim uses it
set-option -g prefix C-a
bind-key C-a last-window
unbind-key C-b
set -g base-index 1 # start windows numbering at 1
setw -g pane-base-index 1 # make pane numbering consistent with windows
set -g renumber-windows on # renumber windows when a window is closed
set -g set-titles on # set terminal title
set -g set-titles-string '□ #S #I #W'
set -g display-panes-time 500 # slightly longer pane indicators display time
# Notifications
setw -g monitor-activity on
setw -g visual-activity on
# Auto rename
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{b;s/{{ .username }}/~/:pane_current_path}'
# Allows us to use C-a a [command] to send commands to a TMUX session inside
# another TMUX session
bind-key a send-prefix
# Activity monitoring
setw -g monitor-activity on
set -g visual-activity on
# don't exit from tmux when closing a session
set -g detach-on-destroy off
# Split windows into panes: CTRL-A + h or v
bind-key h split-window -v -c '#{pane_current_path}'
bind-key v split-window -h -c '#{pane_current_path}'
# Set up resize-pane keys: ALT + left - right - down - up
bind-key -n M-Left resize-pane -L 1
bind-key -n M-Right resize-pane -R 1
bind-key -n M-Down resize-pane -D 1
bind-key -n M-Up resize-pane -U 1
# Switch windows: CTRL-ALT + left or right arrows
bind-key -n C-M-Left previous-window
bind-key -n C-M-Right next-window
set-window-option -g mode-keys vi
# -- copy mode -----------------------------------------------------------------
bind Enter copy-mode # enter copy mode
run -b 'tmux bind -t vi-copy v begin-selection 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi v send -X begin-selection 2> /dev/null || true'
run -b 'tmux bind -t vi-copy C-v rectangle-toggle 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi C-v send -X rectangle-toggle 2> /dev/null || true'
run -b 'tmux bind -t vi-copy y copy-selection 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi y send -X copy-selection-and-cancel 2> /dev/null || true'
run -b 'tmux bind -t vi-copy Escape cancel 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi Escape send -X cancel 2> /dev/null || true'
run -b 'tmux bind -t vi-copy H start-of-line 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi L send -X end-of-line 2> /dev/null || true'
# Move windows on the left (/) or on the right (*)
bind-key / swap-window -t -1
bind-key * swap-window -t +1
# define keystrokes to send favorite commands defined as env var
# ALT-SHIFT-[number]
bind-key M-1 send-keys "$FAVORITE_COMMAND1"
bind-key M-2 send-keys "$FAVORITE_COMMAND2"
bind-key M-3 send-keys "$FAVORITE_COMMAND3"
bind-key M-4 send-keys "$FAVORITE_COMMAND4"
# disposable terminal
bind-key + display-popup -E -w 80% -h 80% "tmux kill-session -t popup 2>/dev/null || true; tmux new-session -d -s popup -c '#{pane_current_path}' \\; set-option -t popup detach-on-destroy on \\; attach -t popup"
# sesh
bind-key "s" run-shell "sesh connect \"$(
sesh list --icons | fzf-tmux -p 80%,70% \
--no-sort --ansi --border-label ' sesh ' --prompt '⚡ ' \
--header ' ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find' \
--bind 'tab:down,btab:up' \
--bind 'ctrl-a:change-prompt(⚡ )+reload(sesh list --icons)' \
--bind 'ctrl-t:change-prompt(🪟 )+reload(sesh list -t --icons)' \
--bind 'ctrl-g:change-prompt(⚙️ )+reload(sesh list -c --icons)' \
--bind 'ctrl-x:change-prompt(📁 )+reload(sesh list -z --icons)' \
--bind 'ctrl-f:change-prompt(🔎 )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
--bind 'ctrl-d:execute(tmux kill-session -t {2..})+change-prompt(⚡ )+reload(sesh list --icons)' \
--preview-window 'right:55%' \
--preview 'sesh preview {}'
)\""
# Reload tmux config
unbind r
bind r source-file ~/.tmux.conf \; display-message "tmux config reloaded!"
# plugin powerkit
set -g @powerkit_theme 'nord'
set -g @powerkit_theme_variant 'dark'
set -g @powerkit_plugins 'ssh,memory,datetime'
set -g @powerkit_session_icon 'auto'
set -g @powerkit_status_position 'bottom'
set -g @powerkit_keybinding_conflict_action 'skip'
set -g @powerkit_plugin_ssh_format 'indicator'
set -g @powerkit_plugin_memory_show_only_on_threshold 'true'
set -g @powerkit_plugin_memory_cache_ttl '20'
# Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'fabioluciano/tmux-powerkit'
set -g @plugin 'azorng/tmux-smooth-scroll'
# run tpm
run -b '~/.tmux/plugins/tpm/tpm'
# =========================== END OF FILE ===================================