dotfiles/dot_tmux.conf.tmpl

166 lines
5.8 KiB
Cheetah
Raw Normal View History

2021-04-07 15:10:57 +02:00
# 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
2021-04-07 15:10:57 +02:00
# increase scrollback buffer size
set -g history-limit 50000
# tmux messages are displayed for 4 seconds
set -g display-time 4000
2023-04-29 22:55:09 +02:00
# screen-256 true color
2023-05-03 08:06:15 +02:00
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",xterm-256color:Tc"
2021-04-07 15:10:57 +02:00
# 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
2025-04-17 15:47:19 +02:00
set -q -g status-utf8 on # expect UTF-8 (tmux lower than 2.2)
2021-04-07 15:10:57 +02:00
setw -q -g utf8 on
2021-04-17 19:05:02 +02:00
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
2021-04-07 15:10:57 +02:00
# 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
2025-01-23 18:00:17 +01:00
set -g set-titles-string '□ #S #I #W'
2021-04-07 15:10:57 +02:00
2022-04-14 13:20:22 +02:00
set -g display-panes-time 500 # slightly longer pane indicators display time
2021-04-07 15:10:57 +02:00
# Notifications
setw -g monitor-activity on
setw -g visual-activity on
# Auto rename
2024-01-22 10:38:22 +01:00
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{b;s/{{ .username }}/~/:pane_current_path}'
2021-04-07 15:10:57 +02:00
2025-04-17 15:47:19 +02:00
# Allows us to use C-a a [command] to send commands to a TMUX session inside
2021-04-07 15:10:57 +02:00
# another TMUX session
bind-key a send-prefix
# Activity monitoring
setw -g monitor-activity on
set -g visual-activity on
2026-01-08 14:26:58 +01:00
# don't exit from tmux when closing a session
set -g detach-on-destroy off
2021-06-04 14:11:35 +02:00
# Split windows into panes: CTRL-A + h or v
2021-04-07 15:10:57 +02:00
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
2021-04-07 15:10:57 +02:00
2021-06-04 14:11:35 +02:00
# Switch windows: CTRL-ALT + left or right arrows
bind-key -n C-M-Left previous-window
bind-key -n C-M-Right next-window
2021-04-07 15:10:57 +02:00
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
2022-07-04 11:02:56 +02:00
# define keystrokes to send favorite commands defined as env var
2025-04-17 15:47:19 +02:00
# ALT-SHIFT-[number]
2022-07-04 11:02:56 +02:00
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"
2025-11-10 17:44:16 +01:00
# disposable terminal
2025-12-29 13:23:14 +01:00
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"
2025-11-10 17:44:16 +01:00
2026-01-08 14:26:58 +01:00
# 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(pj)' \
2026-01-08 14:26:58 +01:00
--bind 'ctrl-d:execute(tmux kill-session -t {2..})+change-prompt(⚡ )+reload(sesh list --icons)' \
--preview-window 'right:55%' \
--preview 'sesh preview {}'
)\""
2021-04-07 15:10:57 +02:00
# Reload tmux config
unbind r
2025-03-24 07:32:43 +01:00
bind r source-file ~/.tmux.conf \; display-message "tmux config reloaded!"
2021-04-07 15:10:57 +02:00
2025-12-28 11:19:32 +01:00
# plugin powerkit
2025-12-26 17:45:46 +01:00
set -g @powerkit_theme 'nord'
set -g @powerkit_theme_variant 'dark'
2025-12-28 11:19:32 +01:00
set -g @powerkit_plugins 'ssh,memory,datetime'
2025-12-26 17:45:46 +01:00
set -g @powerkit_session_icon 'auto'
2025-12-28 11:19:32 +01:00
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'
2025-12-26 17:45:46 +01:00
2022-03-08 15:52:32 +01:00
# Plugins
2021-04-07 15:10:57 +02:00
set -g @plugin 'tmux-plugins/tpm'
2025-12-26 17:45:46 +01:00
set -g @plugin 'fabioluciano/tmux-powerkit'
2025-12-15 09:39:13 +01:00
set -g @plugin 'azorng/tmux-smooth-scroll'
2026-03-13 07:47:00 +01:00
# freeze sessions, thaw them later (prefix + C-s: save all sessions, prefix + C-r: restore from last save)
set -g @plugin 'clanghans/tmux-frost'
# tmux-grep: search across all panes (prefix + /)
set -g @plugin 'cookiecad/tmux-grep'
2021-04-07 15:10:57 +02:00
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
2021-04-07 15:10:57 +02:00
# run tpm
run -b '~/.tmux/plugins/tpm/tpm'
# =========================== END OF FILE ===================================