tmuxrc/tmux.conf

209 lines
6.9 KiB
Plaintext

# vi: syntax=tmux
# vi: filetype=tmux
#
# mkdir -p $HOME/.config/tmux/plugins
# cd $HOME/.config/tmux
# git init
# cd plugins
# git submodule init
# git submodule add https://github.com/tmux-plugins/tpm
# git submodule add https://github.com/tmux-plugins/tmux-prefix-highlight
# git submodule add https://github.com/jaclu/tmux-menus
# git submodule add https://github.com/laktak/extrakto
# git submodule add https://github.com/tmux-plugins/tmux-sidebar
# ----- Prefix -----
# Rebind the prefix to Ctrl+x
unbind-key C-b
set-option -g prefix C-x
bind-key C-x send-prefix
# ----- Panes -----
# Splits open in the current working directory
bind-key '"' split-window -c "#{pane_current_path}"
bind-key '%' split-window -h -c "#{pane_current_path}"
# Bind "a" to toggle sync mode on all panes with an active border color
bind-key a if -F '#{pane_synchronized}' \
'set-window-option synchronize-panes off; \
set-window-option pane-active-border-style fg=colour02; \
set-window-option pane-border-style fg=colour04' \
'set-window-option synchronize-panes on; \
set-window-option pane-active-border-style fg=colour02; \
set-window-option pane-border-style fg=colour02'
# Rebind zoom/unzoom current pane from 'z' to 'Z' and make it repeatable
unbind-key z
bind-key -r Z resize-pane -Z
# Bind 'e' and 'z' as repeatable keys to switch pane and zoom on it
bind-key -r e select-pane -t .+1 \; resize-pane -Z
bind-key -r z select-pane -t .-1 \; resize-pane -Z
# Add a status for each pane with index, title and command
set -g pane-border-status bottom
set -g pane-border-format '#{pane_index} #{pane_title} > #(sleep 1; ps -t #{pane_tty} --no-headers -o command | tail -1)'
# Bind "P" to interactively rename the title of the current pane
bind-key P command-prompt -I 'select-pane -T '
# Seperator colors for current pane
set-option -g pane-active-border-style fg=colour02
# Seperator color for other panes
set-option -g pane-border-style fg=colour04
# ----- Status Bar -----
# Colors for the status bar
set -g status-bg 'colour00'
set -g status-fg 'colour08'
# Contents (gitmux & prefix) on the right of the status bar
set -g status-right '#(gitmux -timeout 3s -cfg ~/.config/gitmux.conf "#{pane_current_path}") #{prefix_highlight}'
set -g status-interval 1
set -g status-right-length 45
# Contents on the left of the status bar
set -g status-left '#[fg=colour03,bg=colour08,bold][#S]#[bg=default] '
set -g status-left-length 32
# Position of the status bar
# (top/bottom)
set -g status-position bottom
# Position of the window status
# (left/centre/right)
set -g status-justify left
# Color of the status bar message
set-option -g message-style bg=colour04,fg=colour08
# ----- Windows -----
# Rebind 'n' and 'p' as repeatable keys to switch windows
bind-key -r n select-window -t:+1
bind-key -r p select-window -t:-1
# open a fzf popup windows changer
bind-key C-k display-popup -E "tmux list-windows | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#I')\$\" | fzf --reverse | xargs tmux select-window -t"
# open a fzf popup session changer
bind-key C-j display-popup -E "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
# open/close a popup scratch session
bind-key C-g if-shell -F '#{==:#{session_name},scratch}' {
detach-client
} {
display-popup -E "tmux new-session -A -s scratch"
}
# Status format for the current window
setw -g window-status-current-format '#[fg=colour06,bg=colour08,bold] #I #W '
# Status format for other windows
setw -g window-status-format '#[fg=colour04,bg=colour08] #I #W '
# Seperator between each window names
set -wg window-status-separator ' '
# Show alert if other window changes?
setw -g monitor-activity off
# Should automatically rename other windows based on the current program?
set -g automatic-rename on
# ----- More options -----
# Emacs key bindings in tmux command prompt (prefix + :) are better than
# vi keys, even for vim users
set -g status-keys emacs
# 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
# Delay for the repeat key (-r) to be available, default is 500
set-option -g repeat-time 1000
# History limit for scrolling back
set -g history-limit 10000
# Increase tmux messages display duration from 750ms to 4s
set -g display-time 4000
# Use mouse to switch windows, adjust panes, etc...
set -g mouse off
# Delay after escape key is passed into the program
set -s escape-time 0
# Use vi styled keys for scrolling & copying
set-window-option -g mode-keys vi
# True color support
set -g default-terminal tmux-256color
set-option -ga terminal-overrides ',rxvt-unicode-256color:Ms=\E]52;%p1%s;%p2%s\007'
# set-clipboard for copying with OSC 52
# to make it work through tmux and ssh you need to use X11Forwarding (default) and "sudo apt install xauth"
set -g allow-passthrough on
set -s set-clipboard on
set -as terminal-features ',rxvt-unicode-256color:clipboard'
# modified copy mode with clipboard output
bind-key -T prefix v copy-mode
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X rectangle-toggle
# ----- Plugins -----
# Tmux plugin manager
set -g @plugin 'tmux-plugins/tpm'
set-environment -g TMUX_PLUGIN_MANAGER_PATH "~/.config/tmux/plugins/"
# Import plugins
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'jaclu/tmux-menus'
set -g @plugin 'tmux-plugins/tmux-sidebar'
set -g @plugin 'laktak/extrakto'
# tmux-prefix_highlight configs
set -g @prefix_highlight_prefix_prompt 'Wait'
set -g @prefix_highlight_copy_prompt 'Copy'
set -g @prefix_highlight_sync_prompt 'Sync'
set -g @prefix_highlight_fg 'colour05'
set -g @prefix_highlight_bg 'colour08'
set -g @prefix_highlight_show_copy_mode 'on'
set -g @prefix_highlight_copy_mode_attr 'fg=colour08,bg=colour03,bold'
set -g @prefix_highlight_show_sync_mode 'on'
set -g @prefix_highlight_sync_mode_attr 'fg=colour08,bg=colour02,bold'
# extrakto configs, open with "Prefix-Tab"
set -g @extrakto_grab_area 'recent'
set -g @extrakto_filter_order 'line word all'
set -g @extrakto_popup_size '90%,60%'
set -g @extrakto_clip_tool_run 'tmux_osc52'
set -g @extrakto_copy_key 'ctrl-y'
set -g @extrakto_insert_key 'enter'
set -g @extrakto_filter_key 'ctrl-f'
set -g @extrakto_grab_key 'ctrl-g'
set -g @extrakto_edit_key 'ctrl-e'
set -g @extrakto_open_key 'ctrl-o'
# tmux-sidebar configs
set -g @sidebar-tree-width '40'
set -g @sidebar-tree-command 'exa -ab --long --git --color always --icons --sort Name --group-directories-first --no-permissions --no-time --no-user'
set -g @sidebar-tree 'C-e'
set -g @sidebar-tree-focus 'C-z'
# Initialize TMUX plugin manager
# (keep this line at the very bottom of tmux.conf)
run -b '~/.config/tmux/plugins/tpm/tpm'