204 lines
6.5 KiB
Bash
204 lines
6.5 KiB
Bash
# Default shell
|
||
set -g default-shell /bin/zsh
|
||
set-option -g prefix C-a
|
||
|
||
# Reload config
|
||
bind r source-file ~/.tmux.conf; display-message "Config Reloaded."
|
||
|
||
# unbind-key “x” from it’s current job of “ask and then close”
|
||
unbind-key x
|
||
# rebind-key it to just “close”
|
||
bind-key x kill-pane
|
||
# unbind-key “x” from it’s current job of “ask and then close”
|
||
bind-key X kill-session
|
||
|
||
set-option -g detach-on-destroy off
|
||
|
||
# Session management
|
||
bind S command-prompt -p "New Session:" "new-session -A -s '%%' -c ~"
|
||
|
||
# List sessions
|
||
bind s switch-client -nn
|
||
|
||
# Popup session selector
|
||
bind 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"
|
||
|
||
# Popup window selector with previous window first
|
||
bind w display-popup -E "tmux list-windows -F '#{window_index} #{window_name} (#{session_name})' | grep -v \"^$(tmux display-message -p '#I')\" | fzf --reverse | cut -d' ' -f1 | xargs -I{} tmux select-window -t {}"
|
||
|
||
# Use choose-tree for interactive session and window navigation
|
||
bind-key W choose-tree -Zw
|
||
|
||
# Bind a key to run the switch_or_create_session function
|
||
bind-key -r f run-shell "tmux neww -n tmux_sessonizer ~/.bin/tmux_sessionizer"
|
||
|
||
# Reduce delay
|
||
set -s escape-time 1
|
||
|
||
# Start windows and panes at 1, not 0
|
||
set -g base-index 1
|
||
|
||
# Split panes using h and v
|
||
bind b split-pane -h -c "#{pane_current_path}"
|
||
bind v split-pane -v -c "#{pane_current_path}"
|
||
|
||
# Switch panes using Alt-arrow without prefix
|
||
bind h select-pane -L
|
||
bind l select-pane -R
|
||
bind k select-pane -U
|
||
bind j select-pane -D
|
||
|
||
# List windows
|
||
bind p previous-window
|
||
bind n next-window
|
||
|
||
# Quick renaming
|
||
bind C switch-client -n -t "#{session_name}"
|
||
bind C-n command-prompt -p "Rename Window: " "rename-window '%%'"
|
||
bind C-r command-prompt -p "Rename Pane: " "rename-pane '%%'"
|
||
|
||
# Automatic renaming panes
|
||
setw -g automatic-rename on
|
||
set -g automatic-rename-format "#{b:pane_current_path}"
|
||
|
||
# Resizing panes with Prefix H, J, K, L
|
||
bind -r H resize-pane -U 5
|
||
bind -r L resize-pane -R 5
|
||
bind -r K resize-pane -U 5
|
||
bind -r J resize-pane -D 5
|
||
|
||
# Alternate clear screen prefix + ctrl l
|
||
bind C-l send-keys 'C-l'
|
||
|
||
# Enable activity alerts
|
||
setw -g monitor-activity on
|
||
set -g visual-activity on
|
||
|
||
# Remove switching delay
|
||
set-option -s escape-time 0
|
||
|
||
# Increase scrollback buffer size
|
||
set-option -g history-limit 50000
|
||
|
||
# Increase message display timeout
|
||
set-option -g display-time 1500
|
||
|
||
# Enable aggressive resize
|
||
set-window-option -g aggressive-resize off
|
||
|
||
# Seamless navigation with neovim panes
|
||
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
|
||
|
||
# Navigate panes
|
||
bind-key -n C-h if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
|
||
bind-key -n C-j if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
|
||
bind-key -n C-k if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
|
||
bind-key -n C-l if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
|
||
|
||
# List of plugins
|
||
set -g @plugin 'tmux-plugins/tpm'
|
||
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||
set -g @plugin 'tmux-plugins/tmux-resurrect'
|
||
set -g @plugin 'tmux-plugins/tmux-continuum'
|
||
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
|
||
set -g @plugin 'dracula/tmux'
|
||
|
||
|
||
# # Set status line
|
||
# set -g status-right '#[fg=blue]#(date "+%%H:%%M %%d-%%b-%%yi")'
|
||
# set -g status-left 'Session: #S | Host: #{hostname} | '
|
||
# set -g status-right '#{?window_bigger,[#[fg=green]\u25B2#[fg=default]],}' # Display arrow if the window has more lines
|
||
# set -g status-right '#{?window_smaller,[#[fg=red]\u25BC#[fg=default]],}' # Display arrow if the window has fewer lines
|
||
# set -g status-right '#{?client_prefix,#[reverse]<Prefix>#[noreverse] ,}' # Display prefix indicator
|
||
# set -g status-right '#{?pane_in_mode,[#[fg=yellow]Copy Mode#[fg=default]],}' # Display copy mode indicator
|
||
# set -g status-right ' #{=21:pane_title}' # Display pane title
|
||
|
||
# Dracula status line
|
||
set -g @dracula-plugins "network weather battery time"
|
||
set -g @dracula-battery-colors "pink dark_gray"
|
||
set -g @dracula-show-powerline true
|
||
set -g @dracula-show-left-icon session
|
||
set -g @dracula-time-format "%F %R"
|
||
set -g @dracula-battery-label "Battery"
|
||
set -g @dracula-show-fahrenheit false
|
||
set -g @dracula-show-flags true
|
||
set -g @dracula-show-empty-plugins false
|
||
|
||
# Status bar style
|
||
set -g status-style fg=default,bg=default
|
||
|
||
# Set the status-right option with a prefix indicator
|
||
set-option -g status-right "[#{?client_prefix, Prefix, Space}]"
|
||
|
||
# Renaming Session the current dir's name
|
||
set-option -g status-interval 5
|
||
set-option -g automatic-rename on
|
||
set-option -g automatic-rename-format '#{b:pane_current_path}'
|
||
|
||
# Default TMUX keybindings
|
||
bind c new-window
|
||
bind '"' split-window -h
|
||
bind % split-window -v
|
||
bind h select-pane -L
|
||
bind l select-pane -R
|
||
bind Left select-pane -L
|
||
bind Right select-pane -R
|
||
bind Up select-pane -U
|
||
bind Down select-pane -D
|
||
bind C-s setw synchronize-panes
|
||
bind Space select-layout next
|
||
bind Tab select-pane -t:.+
|
||
bind q display-panes
|
||
bind -n C-b select-pane -T:.+
|
||
bind z resize-pane -Z
|
||
bind ! break-pane
|
||
bind -r H resize-pane -U 5
|
||
bind -r L resize-pane -R 5
|
||
bind x kill-pane
|
||
|
||
# Copy mode key mappings
|
||
setw -g mode-keys vi
|
||
|
||
# Specify a custom key combination to exit copy mode
|
||
bind-key -T copy-mode-vi Escape send-keys -X cancel
|
||
|
||
# Navigation
|
||
bind-key -T copy-mode-vi 'h' send-keys -X cursor-left
|
||
bind-key -T copy-mode-vi 'j' send-keys -X cursor-down
|
||
bind-key -T copy-mode-vi 'k' send-keys -X cursor-up
|
||
bind-key -T copy-mode-vi 'l' send-keys -X cursor-right
|
||
bind-key -T copy-mode-vi 'w' send-keys -X next-word
|
||
bind-key -T copy-mode-vi 'b' send-keys -X previous-word
|
||
|
||
# Search
|
||
bind-key -T copy-mode-vi '/' send-keys -X search-forward
|
||
bind-key -T copy-mode-vi '?' send-keys -X search-backward
|
||
bind-key -T copy-mode-vi 'n' send-keys -X search-again
|
||
bind-key -T copy-mode-vi 'N' send-keys -X search-again-backward
|
||
|
||
# Scrolling
|
||
bind-key -T copy-mode-vi 'C-u' send-keys -X halfpage-up
|
||
bind-key -T copy-mode-vi 'C-d' send-keys -X halfpage-down
|
||
|
||
# Selection
|
||
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
|
||
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe "xclip -selection clipboard"
|
||
|
||
# Movement
|
||
bind-key -T copy-mode-vi 'g' send-keys -X start-of-line
|
||
bind-key -T copy-mode-vi 'G' send-keys -X end-of-line
|
||
|
||
# Copying and Pasting
|
||
bind-key -T copy-mode-vi 'space' send-keys -X set-mark
|
||
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe "xclip -selection clipboard"
|
||
|
||
# Miscellaneous
|
||
bind-key -T copy-mode-vi '?' send-keys -X list-keys
|
||
bind-key -T copy-mode-vi ':' command-prompt
|
||
bind-key -T copy-mode-vi '~' send-keys -X show-buffer
|
||
|
||
bind-key ? list-keys
|
||
bind-key : command-prompt
|
||
bind-key -n "^" show-buffer
|
||
|
||
run '$HOME/.tmux/plugins/tpm/tpm'
|