From 95b52f98dc0572cf84cf79e2d728d7891134a3fb Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Fri, 21 Dec 2018 02:58:11 -0500 Subject: [PATCH] Cleanup, reorg --- tmux.conf | 118 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 96 insertions(+), 22 deletions(-) diff --git a/tmux.conf b/tmux.conf index b451b05..6562664 100644 --- a/tmux.conf +++ b/tmux.conf @@ -1,14 +1,46 @@ -# Enabled plugins -set -g @plugin 'tmux-plugins/tpm' -set -g @plugin 'tmux-plugins/tmux-cpu' -set -g @plugin 'https://git.linux-help.org/psi-jack/tmux-host.git' -set -g @plugin 'https://git.linux-help.org/psi-jack/tmux-indicators.git' +# ========================== +# === General Settings === +# ========================== + +set -g default-terminal "screen-256color" +set -g history-limit 5000 +set -g buffer-limit 20 +set -sg escape-time 10 +set -g display-time 1000 +setw -g remain-on-exit off +set -g repeat-time 600 +setw -g allow-rename on +setw -g automatic-rename on +setw -g aggressive-resize off + +# Change prefix key to C-a, easier to type, same as "screen" +unbind C-b +set -g prefix C-a + +# Start index of window/pane with 1, because we're humans, not computers +set -g base-index 1 +setw -g pane-base-index 1 + +# Enable mouse support +set -g mouse on # Bindings set -g prefix C-a bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced' +# ========================== +# === Key Bindings === +# ========================== + +# Unbind default key bindings, we're going to override +unbind % # split-window -h +unbind '"' # split-window +unbind l # last-window +unbind & # kill-window +unbind = # choose-buffer +unbind ] # paste-buffer + # Navigation bind -n M-Right next-window bind -n M-Left previous-window @@ -17,17 +49,55 @@ bind -n M-Left previous-window bind-key -n F2 set-window-option synchronize-panes # Window/Session -bind-key n command-prompt -p "rename-session" "rename-session %%" +bind-key n command-prompt -p "rename-window:" -I "#{window_name}" "rename-window '%%'" +bind-key N command-prompt -p "rename-session:" -I "#{session_name}" "rename-session '%%'" bind - split-window -v bind _ split-window -h bind > swap-pane -D # swap current pane with the next one bind < swap-pane -U # swap current pane with the previous one bind C-c new-session +bind Tab last-window +bind C-a last-window +bind X confirm-before -p "kill-window #W? (y/n)" kill-window + +# ================================================ +# === Copy mode, scroll and clipboard === +# ================================================ +set -g @copy_use_osc52_fallback on + +# Prefer vi style key table +setw -g mode-keys vi + +bind p paste-buffer +bind C-p choose-buffer + +# trigger copy mode by (not working for me) +#bind -n M-Up copy-mode + +yank="~/.tmux/yank.sh" + +# Copy selected text +bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "$yank" +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 \;\ +# run "tmux save-buffer - | $yank" +bind -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel "$yank; tmux paste-buffer" +bind -T copy-mode-vi C-j send-keys -X copy-pipe-and-cancel "$yank" +bind-key -T copy-mode-vi D send-keys -X copy-end-of-line \;\ + run "tmux save-buffer - | $yank" +bind-key -T copy-mode-vi A send-keys -X append-selection-and-cancel \;\ + run "tmux save-buffer - | $yank" + +# Copy selection on drag end event, but do not cancel copy mode and do not clear selection +# clear select on subsequence mouse click +#bind -T copy-mode-vi MouseDragEnd1Pane \ +# send-keys -X copy-pipe "$yank" +unbind -T copy-mode-vi MouseDragEnd1Pane +bind -T copy-mode-vi MouseDown1Pane select-pane \;\ + send-keys -X copy-pipe "$yank" \;\ + send-keys -X clear-selection -set -g default-terminal "screen-256color" -set -g base-index 1 -setw -g pane-base-index 1 set -g bell-action any set -g default-command "" set -g default-shell "/bin/zsh" @@ -36,33 +106,24 @@ set -g detach-on-destroy on set -g display-panes-active-colour "#00afff" set -g display-panes-colour "#00afff" set -g display-panes-time 800 -set -g display-time 1000 -set -g history-limit 5000 -set -g mouse on set -g renumber-windows on -set -g escape-time 10 -set -g repeat-time 600 set -g status-keys vi +set -g status-interval 4 set -g visual-activity off set -g visual-bell off set -g visual-silence off -setw -g aggressive-resize off -setw -g allow-rename on setw -g alternate-screen on -setw -g automatic-rename on setw -g clock-mode-style 24 setw -g force-height 0 setw -g force-width 0 setw -g main-pane-height 24 setw -g main-pane-width 80 -setw -g mode-keys vi setw -g monitor-activity on setw -g monitor-bell on setw -g monitor-silence 0 setw -g other-pane-height 0 setw -g other-pane-width 0 -setw -g remain-on-exit off setw -g wrap-search on setw -g xterm-keys on @@ -106,14 +167,27 @@ setw -g window-status-style "fg=#8a8a8a,bg=#080808" setw -g window-style default +# ============================ +# === Plugins === +# ============================ +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-sensible' +set -g @plugin 'tmux-plugins/tmux-cpu' +#set -g @plugin 'tmux-plugins/tmux-yank' +set -g @plugin 'https://git.linux-help.org/psi-jack/tmux-host.git' +set -g @plugin 'https://git.linux-help.org/psi-jack/tmux-indicators.git' + +set -g @yank_action 'copy-pipe' + +# ============================================= +# === Nesting local and remote sessions === +# ============================================= + # Load modular configuration if-shell 'test -n "$SSH_CLIENT"' \ 'source-file ~/.tmux/tmux.remote.conf' \ 'source-file ~/.tmux/tmux.local.conf' -# Start a new session called default, if starting new. -#new-session -s default - # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run -b '~/.tmux/plugins/tpm/tpm'