From 31b98090061a96bab46a9010e7655a780366974d Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 26 Jul 2016 12:38:27 +0800 Subject: Rewrite '_tmux.conf' * Use 'tpm': tmux plugins manager * Tune the status style * Many cleanups --- _tmux.conf | 208 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 104 insertions(+), 104 deletions(-) (limited to '_tmux.conf') diff --git a/_tmux.conf b/_tmux.conf index 33dff6c..cceb403 100644 --- a/_tmux.conf +++ b/_tmux.conf @@ -3,67 +3,51 @@ ## ## Aaron LI ## Created: 2015-01-22 -## Updated: 2016-05-29 +## Updated: 2016-07-26 ## ## References: ## [1] tmux: Productive Mouse-Free Development (by Brian P. Hogan) ## https://pragprog.com/book/bhtmux/tmux -## [2] Copy and Paste in tmux -## http://dudenbostel.leanside.com/2014/01/copy-paste-in-tmux/ +## [2] Making tmux Pretty and Usable - A Guide to Customizing your tmux.conf +## http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/ +## [3] ArchWiki - Tmux +## https://wiki.archlinux.org/index.php/tmux +## [4] Practical Tmux +## http://mutelight.org/practical-tmux +## [5] Tmux Plugin Manager +## https://github.com/tmux-plugins/tpm +## [6] Tmux themepack +## https://github.com/jimeh/tmux-themepack ## -## Settings the prefix from 'C-b' to 'C-a' -#set-option -g prefix C-a -#unbind-key C-b -#bind-key C-a send-prefix +## 'C-b' is not acceptable: Vim uses it! +unbind-key C-b +set-option -g prefix C-a -## Settings the delay between prefix and command -set-option -gs escape-time 1 - -## Set the base index for windows to 1 instead of 0 +## Start window numbering at 1 set-option -g base-index 1 -## Set the base index for panes to 1 instead of 0 -set-window-option -g pane-base-index 1 - -## Reload the configuration file with 'Prefix-r' -bind r source-file ~/.tmux.conf \; display "Reloaded!" - -## More straightforward key bindings for splitting panes -unbind % -bind | split-window -h -unbind '"' -bind - split-window -v - -## Move between the split panes -bind h select-pane -L -bind j select-pane -D -bind k select-pane -U -bind l select-pane -R +## Renumber the windows when a window is closed +set-option -g renumber-windows on -## C-h/C-l to cycle through windows -bind -r C-h select-window -t :- -bind -r C-l select-window -t :+ - -## Quich cycle through windows -#bind-key -n C-p previous-window -#bind-key -n C-n next-window +## Start pane numbering at 1 +set-window-option -g pane-base-index 1 -## Pane resizing -bind -r H resize-pane -L 5 -bind -r J resize-pane -D 5 -bind -r K resize-pane -U 5 -bind -r L resize-pane -R 5 +# URxvt tab like window control +bind-key -n S-Down new-window +bind-key -n S-Left previous-window +bind-key -n S-Right next-window +bind-key -n C-Left swap-window -t -1 +bind-key -n C-Right swap-window -t +1 -## Mouse support -#set-window-option -g mode-mouse on -#set-option -g mouse-select-window on -#set-option -g mouse-select-pane on -#set-option -g mouse-resize-pane on +## Detach tmux instead of exit +bind-key -n C-d detach -## Set the default terminal mode -set-option -g default-terminal "screen-256color" +## Mouse control (>= v2.1) +set-option -g mouse on +bind-key m set-option -g mouse on \; display "Mouse: ON" +bind-key M set-option -g mouse off \; display "Mouse: OFF" ## Terminal settings # Override terminal's default Cr (color reset) to avoid the strange @@ -71,64 +55,80 @@ set-option -g default-terminal "screen-256color" # Credit: https://github.com/tmux/tmux/issues/266 set-option -g terminal-overrides ',xterm*:Cr=\E]12;gray\007' -## Enable activity alerts -set-window-option -g monitor-activity on -set-option -g visual-activity on - -## Vi mode -set-window-option -g mode-keys vi -set-option -g status-keys vi - -## Set copy mode -# start copy mode with 'Prefix-Escape' -bind-key Escape copy-mode -# paste the latest buffer with 'Prefix-p' -bind-key p paste-buffer -# delete the most recently copied buffer -bind-key + delete-buffer - -# vi-copy settings -bind-key -t vi-copy 'v' begin-selection -bind-key -t vi-copy 'y' copy-selection -# change between line- and column-wise selection -bind-key -t vi-copy 'V' rectangle-toggle -bind-key -t vi-copy 'Y' copy-end-of-line - -## Scrollback history -set-option -g history-limit 5000 - -## How long to display messages and other indicators (unit: ms) -set-option -g display-time 3000 - -## Send multiple commands without pressing Prefix again -set-option -g repeat-time 1000 - ## Maximize and restore a pane -unbind Up -bind Up new-window -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp -unbind Down -bind Down last-window \; swap-pane -s tmp.1 \; kill-window -t tmp +unbind-key Up +bind-key Up new-window -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp +unbind-key Down +bind-key Down last-window \; swap-pane -s tmp.1 \; kill-window -t tmp ## Log output to a text file on demand -bind P pipe-pane -o "cat >> ~/#W.log" \; display "Toggled logging to ~/#W.log" - -### Styles ### - -## Set the status line -set-option -g status-style "bg=default" -set-option -g status-justify centre -set-option -g status-left-length 30 -set-option -g status-right-length 30 -set-option -g status-left " #[fg=yellow,bold]#h:#[fg=blue,bold]#S #[fg=magenta,bold]|#[default]" -set-option -g status-right "#[fg=magenta,bold]| #[fg=yellow,bold]%a %m/%d #[fg=blue,bold]%H:%M " - -set-window-option -g window-status-style "fg=blue,bold" -set-window-option -g window-status-current-style "fg=blue,bold,reverse" -set-window-option -g window-status-format "#I:#{=10:window_name}#F" -set-window-option -g window-status-current-format "#I:#W#F" - -## command/message line style -set-option -g message-style "fg=white,bold,bg=blue" - +bind-key P pipe-pane -o "cat >> ~/#W.log" \; display "Toggled logging to ~/#W.log" + + +###### Appearance ###### + +## Panes +set-option -g pane-border-style "fg=default,bg=default" +set-option -g pane-active-border-style "fg=blue,bg=default" + +## Status bar design +# status line +set-option -g status-justify centre +set-option -g status-left-length 20 +set-option -g status-right-length 20 +set-option -g status-style "bg=default,bold" +set-option -g status-left " #[fg=yellow]#h:#[fg=blue]#S #[fg=magenta]>>#[default]" +set-option -g status-right "#[fg=magenta]<< #[fg=yellow]%a %m/%d #[fg=blue]%H:%M " + +# window status +set-option -g window-status-separator " " +set-window-option -g window-status-style "fg=blue,bold" +set-window-option -g window-status-current-style "fg=blue,bold,reverse" +set-window-option -g window-status-bell-style "fg=red,bold" +set-window-option -g window-status-format "#I:#{=10:window_name}#F" +set-window-option -g window-status-current-format "#[fg=yellow]#I:#[fg=blue]#W#[fg=green]#F#[default]" + +# window mode +set-window-option -g mode-style "fg=yellow,bg=default,bold" +set-window-option -g clock-mode-colour yellow +set-window-option -g clock-mode-style 24 + +# messaging +set-option -g message-style "fg=white,bg=blue,bold" +set-option -g message-command-style "fg=white,bg=default,bold" + +# loud or quiet? +set-option -g visual-activity off +set-option -g visual-bell off +set-option -g visual-silence off +set-option -g bell-action none +set-window-option -g monitor-activity off + + +###### Tmux Plugins ###### + +# List of plugins +set-option -g @plugin "tmux-plugins/tpm" +# Basic tmux settings everyone can agree on +set-option -g @plugin "tmux-plugins/tmux-sensible" +# Persists tmux environment across system restarts +set-option -g @plugin "tmux-plugins/tmux-resurrect" +# Copy to system clipboard +set-option -g @plugin "tmux-plugins/tmux-yank" +# Enhance tmux search +set-option -g @plugin "tmux-plugins/tmux-copycat" +# Continuous saving of tmux environment +set-option -g @plugin "tmux-plugins/tmux-continuum" +# Standard pane key-bindings for tmux +set-option -g @plugin "tmux-plugins/tmux-pain-control" +# Tmux key bindings for quick opening of a highlighted file or URL +set-option -g @plugin "tmux-plugins/tmux-open" + +# Automatic TPM installation +# Credit: https://github.com/tmux-plugins/tpm/blob/master/docs/automatic_tpm_installation.md +if "test ! -d ~/.tmux/plugins/tpm" \ + "run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm'" + +# Initialize Tmux plugin manager (keep this at the very bottom) +run "~/.tmux/plugins/tpm/tpm" -# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=tmux: # -- cgit v1.2.2