diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf new file mode 100644 index 00000000..63ed2f12 --- /dev/null +++ b/.config/tmux/tmux.conf @@ -0,0 +1,121 @@ +yank="xsel -i --clipboard" + +# GENERAL SETTINGS +set -g default-terminal "screen-256color" +set -g history-limit 20000 +set -g buffer-limit 20 +set -sg escape-time 0 +set -g display-time 1500 +set -g remain-on-exit off +set -g repeat-time 300 +setw -g allow-rename off +setw -g automatic-rename off +setw -g aggressive-resize on +set -g prefix C-a +set -g set-titles on +set -g set-titles-string "#I:#W" +set -g mouse off +setw -g mode-keys vi +set -g visual-activity on + +# STATUS BAR SETTINGS +black="color0" +red="color1" +green="color2" +yellow="color3" +blue="color4" +purple="color5" +cyan="color6" +gray="color7" +darkgray="color8" +white="color15" + +set -g mode-style "fg=default,bg=$blue" +set -g message-style "fg=$blue,bg=$black" +set -g status-style "fg=$gray,bg=$black" +setw -g window-status-format " #I:#W " +setw -g window-status-current-style "fg=$black,bold,bg=$blue" +setw -g window-status-current-format " #I:#W# " +setw -g window-status-activity-style "fg=$gray" +setw -g pane-active-border-style "fg=$blue" + +set -g status on +set -g status-interval 5 +set -g status-position bottom +set -g status-justify left +set -g status-right-length 100 + +# BINDINGS +unbind 'C-b' +unbind '$' +unbind ',' +unbind '%' +unbind '"' +unbind '}' +unbind '{' +unbind '[' +unbind ']' +unbind "'" +unbind 'n' +unbind 'p' +unbind 'l' +unbind 'M' +unbind 'o' +unbind '&' +unbind '#' +unbind '=' +unbind 'z' +unbind 'Space' +unbind 'M-Up' +unbind 'M-Down' +unbind 'M-Right' +unbind 'M-Left' + +bind 'C-r' source-file ~/$XDG_CONFIG_HOME/tmux/tmux.conf \; display "Config reloaded" +bind 'r' command-prompt -I "#{window_name}" "rename-window '%%'" +bind 'R' command-prompt -I "#{session_name}" "rename-session '%%'" +bind 'c' new-window -c "#{pane_current_path}" +bind '|' split-window -h -c "#{pane_current_path}" +bind '_' split-window -v -c "#{pane_current_path}" +bind -r 'C-[' previous-window +bind -r 'C-]' next-window +bind -r '[' select-pane -t :.- +bind -r ']' select-pane -t :.+ +bind -r 'Tab' last-window # cycle thru MRU tabs +bind -r 'C-o' swap-pane -D +bind '+' resize-pane -Z +bind 'L' command-prompt -p "Link window from (session:window): " "link-window -s %% -a" +bind 'Space' if '[ #{pane_index} -eq 2 ]' \ + 'swap-pane -s "!"' \ + 'select-pane -t:.1 ; swap-pane -d -t 1 -s "!"' +bind 'x' kill-pane +bind 'X' kill-window +bind 'C-x' confirm-before -p "kill other windows? (y/n)" "kill-window -a" +bind 'Q' confirm-before -p "kill-session #S? (y/n)" kill-session +bind 'C-u' command-prompt -p "Session to merge with: " \ + "run-shell 'yes | head -n #{session_windows} | xargs -I {} -n 1 tmux movew -t %%'" +bind 'd' detach +bind 'D' if -F '#{session_many_attached}' \ + 'confirm-before -p "Detach other clients? (y/n)" "detach -a"' \ + 'display "Session has only 1 client attached"' +bind 'C-s' if -F '#{s/off//:status}' 'set status off' 'set status on' +bind 'm' setw monitor-activity \; display-message 'Monitor window activity [#{?monitor-activity,ON,OFF}]' +bind 'M' if -F '#{monitor-silence}' \ + 'setw monitor-silence 0 ; display-message "Monitor window silence [OFF]"' \ + 'command-prompt -p "Monitor silence: interval (s)" "setw monitor-silence %%"' +bind 'p' paste-buffer +bind 'C-p' choose-buffer +bind 'C-c' copy-mode +bind -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel "$yank" +bind -T copy-mode-vi 'Y' send-keys -X copy-line-and-cancel \; run "tmux save-buffer - | $yank" +# These binds allow toggling of keybind handling by the root tmux session +# This is helpful when nesting tmux sessions (i.e. when using SSH) +bind -T root F12 \ + set prefix None \;\ + set key-table off \;\ + if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\ + refresh-client -S +bind -T off F12 \ + set -u prefix \;\ + set -u key-table \;\ + refresh-client -S