tmux
This commit is contained in:
@ -24,56 +24,60 @@ Tested and working on Linux, OSX and Cygwin.
|
||||
|
||||
### Options
|
||||
|
||||
# utf8 is on
|
||||
set -g utf8 on
|
||||
set -g status-utf8 on
|
||||
```tmux
|
||||
# Address vim mode switching delay (http://superuser.com/a/252717/65504)
|
||||
set -s escape-time 0
|
||||
|
||||
# address vim mode switching delay (http://superuser.com/a/252717/65504)
|
||||
set -s escape-time 0
|
||||
# Increase scrollback buffer size from 2000 to 50000 lines
|
||||
set -g history-limit 50000
|
||||
|
||||
# increase scrollback buffer size
|
||||
set -g history-limit 50000
|
||||
# Increase tmux messages display duration from 750ms to 4s
|
||||
set -g display-time 4000
|
||||
|
||||
# tmux messages are displayed for 4 seconds
|
||||
set -g display-time 4000
|
||||
# Refresh 'status-left' and 'status-right' more often, from every 15s to 5s
|
||||
set -g status-interval 5
|
||||
|
||||
# refresh 'status-left' and 'status-right' more often
|
||||
set -g status-interval 5
|
||||
# (OS X) Fix pbcopy/pbpaste for old tmux versions (pre 2.6)
|
||||
set -g default-command "reattach-to-user-namespace -l $SHELL"
|
||||
|
||||
# set only on OS X where it's required
|
||||
set -g default-command "reattach-to-user-namespace -l $SHELL"
|
||||
# Upgrade $TERM
|
||||
set -g default-terminal "screen-256color"
|
||||
|
||||
# upgrade $TERM
|
||||
set -g default-terminal "screen-256color"
|
||||
# Emacs key bindings in tmux command prompt (prefix + :) are better than
|
||||
# vi keys, even for vim users
|
||||
set -g status-keys emacs
|
||||
|
||||
# emacs key bindings in tmux command prompt (prefix + :) are better than
|
||||
# vi keys, even for vim users
|
||||
set -g status-keys emacs
|
||||
# Focus events enabled for terminals that support them
|
||||
set -g focus-events on
|
||||
|
||||
# focus events enabled for terminals that support them
|
||||
set -g focus-events on
|
||||
|
||||
# super useful when using "grouped sessions" and multi-monitor setup
|
||||
setw -g aggressive-resize on
|
||||
# Super useful when using "grouped sessions" and multi-monitor setup
|
||||
setw -g aggressive-resize on
|
||||
```
|
||||
|
||||
### Key bindings
|
||||
|
||||
# easier and faster switching between next/prev window
|
||||
bind C-p previous-window
|
||||
bind C-n next-window
|
||||
```tmux
|
||||
# Easier and faster switching between next/prev window
|
||||
bind C-p previous-window
|
||||
bind C-n next-window
|
||||
```
|
||||
|
||||
Above bindings enhance the default `prefix + p` and `prefix + n` bindings by
|
||||
allowing you to hold `Ctrl` and repeat `a + p`/`a + n` (if your prefix is
|
||||
`C-a`), which is a lot quicker.
|
||||
|
||||
# source .tmux.conf as suggested in `man tmux`
|
||||
bind R source-file '~/.tmux.conf'
|
||||
```tmux
|
||||
# Source .tmux.conf as suggested in `man tmux`
|
||||
bind R source-file '~/.tmux.conf'
|
||||
```
|
||||
|
||||
"Adaptable" key bindings that build upon your `prefix` value:
|
||||
|
||||
# if prefix is 'C-a'
|
||||
bind C-a send-prefix
|
||||
bind a last-window
|
||||
```tmux
|
||||
# If prefix is 'C-a'
|
||||
bind C-a send-prefix
|
||||
bind a last-window
|
||||
```
|
||||
|
||||
If prefix is `C-b`, above keys will be `C-b` and `b`.<br/>
|
||||
If prefix is `C-z`, above keys will be `C-z` and `z`... you get the idea.
|
||||
@ -82,7 +86,9 @@ If prefix is `C-z`, above keys will be `C-z` and `z`... you get the idea.
|
||||
|
||||
Add plugin to the list of TPM plugins in `.tmux.conf`:
|
||||
|
||||
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||
```tmux
|
||||
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||
```
|
||||
|
||||
Hit `prefix + I` to fetch the plugin and source it. That's it!
|
||||
|
||||
@ -94,7 +100,9 @@ Clone the repo:
|
||||
|
||||
Add this line to the bottom of `.tmux.conf`:
|
||||
|
||||
run-shell ~/clone/path/sensible.tmux
|
||||
```tmux
|
||||
run-shell ~/clone/path/sensible.tmux
|
||||
```
|
||||
|
||||
Reload TMUX environment with `$ tmux source-file ~/.tmux.conf`, and that's it.
|
||||
|
||||
|
29
tmux/.tmux/plugins/tmux-sensible/sensible.tmux
Normal file → Executable file
29
tmux/.tmux/plugins/tmux-sensible/sensible.tmux
Normal file → Executable file
@ -11,7 +11,7 @@ is_osx() {
|
||||
}
|
||||
|
||||
iterm_terminal() {
|
||||
[[ "$TERM_PROGRAM" =~ ^iTerm ]]
|
||||
[[ "${TERM_PROGRAM}" =~ ^iTerm || "${LC_TERMINAL}" =~ ^iTerm ]]
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
@ -45,7 +45,7 @@ server_option_value_not_changed() {
|
||||
}
|
||||
|
||||
key_binding_not_set() {
|
||||
local key="$1"
|
||||
local key="${1//\\/\\\\}"
|
||||
if $(tmux list-keys | grep -q "${KEY_BINDING_REGEX}${key}[[:space:]]"); then
|
||||
return 1
|
||||
else
|
||||
@ -64,15 +64,20 @@ key_binding_not_changed() {
|
||||
fi
|
||||
}
|
||||
|
||||
get_tmux_config() {
|
||||
local tmux_config_xdg="${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf"
|
||||
local tmux_config="$HOME/.tmux.conf"
|
||||
|
||||
if [ -f "${tmux_config_xdg}" ]; then
|
||||
echo "${tmux_config_xdg}"
|
||||
else
|
||||
echo ${tmux_config}
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
# OPTIONS
|
||||
|
||||
# enable utf8 (option removed in tmux 2.2)
|
||||
tmux set-option -g utf8 on 2>/dev/null
|
||||
|
||||
# enable utf8 in tmux status-left and status-right (option removed in tmux 2.2)
|
||||
tmux set-option -g status-utf8 on 2>/dev/null
|
||||
|
||||
# address vim mode switching delay (http://superuser.com/a/252717/65504)
|
||||
if server_option_value_not_changed "escape-time" "500"; then
|
||||
tmux set-option -s escape-time 0
|
||||
@ -153,9 +158,11 @@ main() {
|
||||
|
||||
# source `.tmux.conf` file - as suggested in `man tmux`
|
||||
if key_binding_not_set "R"; then
|
||||
tmux bind-key R run-shell ' \
|
||||
tmux source-file ~/.tmux.conf > /dev/null; \
|
||||
tmux display-message "Sourced .tmux.conf!"'
|
||||
local tmux_config=$(get_tmux_config)
|
||||
|
||||
tmux bind-key R run-shell " \
|
||||
tmux source-file ${tmux_config} > /dev/null; \
|
||||
tmux display-message 'Sourced ${tmux_config}!'"
|
||||
fi
|
||||
}
|
||||
main
|
||||
|
Reference in New Issue
Block a user