aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--_tmux.conf372
m---------_tmux/plugins/tpm0
3 files changed, 227 insertions, 148 deletions
diff --git a/.gitmodules b/.gitmodules
index 576fef1..5f30a1d 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,3 @@
[submodule "dotvim"]
path = dotvim
url = git@github.com:liweitianux/dotvim.git
-[submodule "tmux-tpm"]
- path = _tmux/plugins/tpm
- url = https://github.com/tmux-plugins/tpm
diff --git a/_tmux.conf b/_tmux.conf
index 8ac0d59..a0709bb 100644
--- a/_tmux.conf
+++ b/_tmux.conf
@@ -1,154 +1,236 @@
+#
+# ~/.tmux.conf
+# ------------
+# See tmux(1) for more information
+#
+#
+# References
+# ----------
+# [1] tmux: Productive Mouse-Free Development (by Brian P. Hogan)
+# https://pragprog.com/book/bhtmux/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
+# [7] Oh My Tmux!
+# https://github.com/gpakosz/.tmux
+#
+# Tips
+# ----
+# * With mouse mode enabled, it is not allowed to select text with mouse.
+# However, pressing "Shift" key while doing things with the mouse will
+# overrides the mouse protocol and lets you select/paste. This behavior
+# is documented in xterm(1) and also supported by most terminals.
+# Credit: https://unix.stackexchange.com/a/332425
+#
+#
+# Aaron LI
+# 2015-01-22
+#
+# 2017-09-03 : Rewrite; drop plugins (with TPM)...
+#
+
+# Start window and pane numbering at 1
+set -g base-index 1
+setw -g pane-base-index 1
+
+# Renumber the windows when a window is closed
+set -g renumber-windows on
+
+# Automatically set window title
+set -g set-titles on
+setw -g automatic-rename on
+# Don't allow programs to change the window name
+set -g allow-rename off
+
+# Use vi-style key bindings in the status line
+set -g status-keys vi
+# Use vi-style key bindings in copy and choice modes
+setw -g mode-keys vi
+
+# Disable the delay between an escape key press and subsequent characcters
+set -sg escape-time 0
+
+# Enable UTF-8
+set -g status-utf8 on
+setw -g utf8 on
+
+# Increase the scrollback history limit
+set -g history-limit 1000
+
+# Lock after 15 minutes
+set -g lock-after-time 1800
+
+# Keep windows around after they exit
+# On exit, the pane will display the message "Pane is dead" until it is
+# closed with the command "kill-pane" or "kill-window", or a new command
+# is started there with "respawn-pane" or "respawn-window".
+#set -g remain-on-exit on
+
+# Turn on xterm-keys so that additional function keys get escape sequences
+set -g xterm-keys on
+
+# Turn the mouse on, but without copy mode dragging
+set -g mouse on
+unbind -n MouseDrag1Pane
+unbind -T copy-mode MouseDrag1Pane
+
+# Change the default $TERM to tmux-256color
+set -g default-terminal "tmux-256color"
+
+# Enable RGB colour if running in xterm(1)
+set -sa terminal-overrides ",xterm*:Tc"
+# Override terminal's default Cr (color reset) to avoid the strange
+# 'char+112' when just exited the tmux session.
+# Credit: https://github.com/tmux/tmux/issues/266
+set -sa terminal-overrides ',xterm*:Cr=\E]12;gray\007'
+
+
##
-## ~/.tmux.conf
-## See tmux(1) for details.
-##
-## Aaron LI
-## Created: 2015-01-22
-## Updated: 2016-07-30
-##
-## References:
-## [1] tmux: Productive Mouse-Free Development (by Brian P. Hogan)
-## https://pragprog.com/book/bhtmux/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
+## Key bindings
##
+# Change the prefix key to C-a
+set -g prefix C-a
+unbind C-b
+bind C-a send-prefix
+
+# Get the command prompt more quickly
+unbind \;
+bind \; command-prompt
+
+# Detach tmux instead of exit
+bind -n C-d detach
+
+# Sane window split keybinds
+unbind '"'
+unbind %
+bind | split-window -h -c '#{pane_current_path}'
+bind - split-window -v -c '#{pane_current_path}'
+
+# Pane switching
+bind h select-pane -L
+bind j select-pane -D
+bind k select-pane -U
+bind l select-pane -R
+bind -n M-Left select-pane -L
+bind -n M-Right select-pane -R
+bind -n M-Up select-pane -U
+bind -n M-Down select-pane -D
+
+# Pane resizing
+bind -r M-h resize-pane -L 5
+bind -r M-j resize-pane -D 5
+bind -r M-k resize-pane -U 5
+bind -r M-l resize-pane -R 5
-## 'C-b' is not acceptable: Vim uses it!
-unbind-key C-b
-set-option -g prefix C-a
+# URxvt tab like window control
+bind -n S-Down new-window
+bind -n S-Left previous-window
+bind -n S-Right next-window
+bind -n C-Left swap-window -t -1
+bind -n C-Right swap-window -t +1
-## Use 'vi' key bindings in copy and choice modes
-set-window-option -g mode-keys vi
+# Enable/disable mouse mode
+bind m set -g mouse on\; display "Mouse: ON"
+bind M set -g mouse off\; display "Mouse: OFF"
-## Start window and pane numbering at 1
-set-option -g base-index 1
-set-window-option -g pane-base-index 1
+# Keys to toggle monitoring activity in a window, and synchronize-panes
+#bind m set monitor-activity
+bind S set synchronize-panes\; display 'synchronize-panes #{?synchronize-panes,on,off}'
-## Renumber the windows when a window is closed
-set-option -g renumber-windows on
+# Reload Tmux configuration
+bind R source-file ~/.tmux.conf\; display "Configuration reloaded."
-# 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
-
-## Detach tmux instead of exit
-bind-key -n C-d detach
-
-## Copy mode settings
-bind-key Escape copy-mode
-bind-key p paste-buffer
-bind-key -t vi-copy "v" begin-selection
-bind-key -t vi-copy "y" copy-selection
-# toggle between line- and column-wise selection
-bind-key -t vi-copy "V" rectangle-toggle
-
-## 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
-# "xterm-256color" for tmux has problem with special keys (e.g., Home, End)
-# bindings in zsh.
-# Credit: https://stackoverflow.com/a/18601007/4856091
-set-option -g default-terminal screen-256color
-# Override terminal's default Cr (color reset) to avoid the strange
-# 'char+112' when just exited the tmux session.
-# Credit: https://github.com/tmux/tmux/issues/266
-set-option -g terminal-overrides ',xterm*:Cr=\E]12;gray\007'
-
-set-window-option -g xterm-keys on
-
-## Maximize and restore a pane
-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-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 30
-set-option -g status-right-length 30
-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"
-
-## Plugin settings
-# tmux-yank:
-set-option -g @shell_mode 'vi'
-
-# 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"
+# Do not display the original window's name when renaming it
+bind , command-prompt -p "(rename-window '#W')" "rename-window '%%'"
+# Do the same for session renaming
+bind '$' command-prompt -p "(rename-session '#S')" "rename-session '%%'"
+
+
+##
+## Appearance
+##
+
+# Status line
+set -g status-justify centre
+set -g status-left-length 30
+set -g status-right-length 30
+set -g status-style "bg=default,bold"
+set -g status-left " #[fg=yellow]#h:#[fg=blue]#S #[fg=magenta]>>#[default]"
+set -g status-right "#[fg=magenta]<< #[fg=yellow]%a %m/%d #[fg=blue]%H:%M "
+
+# If running inside tmux ($TMUX is set), then change the status line to red
+%if #{TMUX}
+set -g status-bg red
+%endif
+
+# Window status
+set -g window-status-separator " "
+setw -g window-status-style "fg=blue,bold"
+setw -g window-status-current-style "fg=blue,bold,reverse"
+setw -g window-status-bell-style "fg=red,bold"
+setw -g window-status-format "#I:#{=10:window_name}#F"
+setw -g window-status-current-format "#[fg=yellow]#I:#[fg=blue]#W#[fg=green]#F#[default]"
+
+# Window mode
+setw -g mode-style "fg=yellow,bg=default,bold"
+setw -g clock-mode-colour yellow
+setw -g clock-mode-style 24
+
+# Messaging
+set -g message-style "fg=white,bg=blue,bold"
+set -g message-command-style "fg=white,bg=default,bold"
+
+# Highlight windows with activity in the status line
+setw -g monitor-activity on
+# Disable bell action and activity messages
+set -g bell-action none
+set -g visual-activity off
+
+# Pane
+set -g pane-border-style "fg=default,bg=default"
+set -g pane-active-border-style "fg=blue,bg=default"
+
+
+##
+## Deal with different syntax between different versions!
+##
+# Credit: https://stackoverflow.com/a/40902312/1046584
+run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | cut -c 6-)"
+
+# In version 2.1 "mouse" replaced the previous 4 mouse options
+if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.1" | bc)" = 1 ]' \
+ "set -g mouse on"
+
+# UTF8 is autodetected in 2.2 onwards, but errors if explicitly set
+if-shell -b '[ "$(echo "$TMUX_VERSION < 2.2" | bc)" = 1 ]' \
+ "set -g utf8 on; set -g status-utf8 on; set -g mouse-utf8 on"
+
+# New keybindings for vi-mode
+# Credit: https://shapeshed.com/custom-vim-bindings-in-tmux-2-4/
+# See also: https://github.com/tmux/tmux/issues/754
+if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.4" | bc)" = 1 ]' \
+ "bind -T copy-mode-vi 'v' send -X begin-selection; \
+ bind -T copy-mode-vi 'V' send -X select-line; \
+ bind -T copy-mode-vi 'r' send -X rectangle-toggle; \
+ bind -T copy-mode-vi 'y' send -X copy-pipe-and-cancel \
+ 'xclip -in -selection clipboard'"
+if-shell -b '[ "$(echo "$TMUX_VERSION < 2.4" | bc)" = 1 ]' \
+ "bind Escape copy-mode; \
+ bind p paste-buffer; \
+ bind -t vi-copy Escape cancel; \
+ bind -t vi-copy v begin-selection; \
+ bind -t vi-copy V select-line; \
+ bind -t vi-copy r rectangle-toggle; \
+ bind -t vi-copy y copy-pipe 'xclip -in -selection clipboard'"
+
+
+# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=tmux: #
diff --git a/_tmux/plugins/tpm b/_tmux/plugins/tpm
deleted file mode 160000
-Subproject 51ff07a729b4b67f692936ad75cb0650149afbb