mirror of
https://github.com/tmux-plugins/tmux-sensible.git
synced 2025-09-08 18:32:53 +00:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
615906df94 | |||
4967aa0ce7 | |||
fa3e8b91ea | |||
74c4a76bfa | |||
89a51c86e3 | |||
47df9983a9 | |||
6a9c4a78ff | |||
97904bc483 |
@ -2,6 +2,15 @@
|
||||
|
||||
### master
|
||||
|
||||
### v1.1.0, 2014-08-30
|
||||
- bugfix: determine the default shell from the $SHELL env var on OS X
|
||||
- set `mode-mouse on` by default
|
||||
- do not make any decision about the prefix, just enhance it
|
||||
- update `README.md`. List options set in the plugin.
|
||||
- do *not* set `mode-mouse on` by default because some users don't like it
|
||||
- if a user changes default prefix but binds `C-b` to something else, do not
|
||||
unbind `C-b`
|
||||
|
||||
### v1.0.0, 2014-07-30
|
||||
- initial work on the plugin
|
||||
- add readme
|
||||
|
59
README.md
59
README.md
@ -13,11 +13,6 @@ Inspired by [vim-sensible](https://github.com/tpope/vim-sensible).
|
||||
- **no overriding** of user defined settings.<br/>
|
||||
Your existing `.tmux.conf` settings are respected and they won't be changed.
|
||||
That way you can use `tmux-sensible` if you have a few specific options.
|
||||
See [feature section](#example-feature) for an example.
|
||||
- [source code](https://github.com/tmux-plugins/tmux-sensible/blob/master/sensible.tmux)
|
||||
is the authoritative documentation.<br/>
|
||||
It's really not that scary and you should have a look, even if you're a
|
||||
tmux beginner.
|
||||
|
||||
### Goals
|
||||
|
||||
@ -25,16 +20,56 @@ Inspired by [vim-sensible](https://github.com/tpope/vim-sensible).
|
||||
- remove clutter from your `.tmux.conf`
|
||||
- educate new tmux users about basic options
|
||||
|
||||
### Example feature
|
||||
### Options
|
||||
|
||||
Sets tmux prefix to `Ctrl-a`.
|
||||
# utf8 is on
|
||||
set -g utf8 on
|
||||
set -g status-utf8 on
|
||||
|
||||
# set prefix to `Ctrl-a`
|
||||
tmux set-option -g prefix C-a
|
||||
tmux unbind-key C-b
|
||||
# address vim mode switching delay (http://superuser.com/a/252717/65504)
|
||||
set -s escape-time 0
|
||||
|
||||
Since user defined `.tmux.conf` settings are respected, if prefix is set to
|
||||
`Ctrl-z` - it won't be overriden!
|
||||
# increase scrollback buffer size
|
||||
set -g history-limit 50000
|
||||
|
||||
# tmux messages are displayed for 4 seconds
|
||||
set -g display-time 4000
|
||||
|
||||
# refresh 'status-left' and 'status-right' more often
|
||||
set -g status-interval 5
|
||||
|
||||
# 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"
|
||||
|
||||
# enable mouse features for terminals that support it
|
||||
set -g mouse-resize-pane on
|
||||
set -g mouse-select-pane on
|
||||
set -g mouse-select-window on
|
||||
|
||||
# emacs key bindings in tmux command prompt (prefix + :) are better than
|
||||
# vi keys, even for vim users
|
||||
set -g status-keys emacs
|
||||
|
||||
### Key bindings
|
||||
|
||||
# easier and faster switching between next/prev window
|
||||
bind C-p previous-window
|
||||
bind C-n next-window
|
||||
|
||||
# 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
|
||||
|
||||
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.
|
||||
|
||||
### Installation with [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) (recommended)
|
||||
|
||||
|
@ -7,18 +7,29 @@ is_osx() {
|
||||
[ "$platform" == "Darwin" ]
|
||||
}
|
||||
|
||||
# returns prefix key, e.g. 'C-a'
|
||||
prefix() {
|
||||
tmux show-option -gv prefix
|
||||
}
|
||||
|
||||
# if prefix is 'C-a', this function returns 'a'
|
||||
prefix_without_ctrl() {
|
||||
local prefix="$(prefix)"
|
||||
echo "$prefix" | cut -d '-' -f2
|
||||
}
|
||||
|
||||
option_value_not_changed() {
|
||||
local option="$1"
|
||||
local default_value="$2"
|
||||
local option_value=$(tmux show-option -gv "$option")
|
||||
[ $option_value == $default_value ]
|
||||
[ "$option_value" == "$default_value" ]
|
||||
}
|
||||
|
||||
server_option_value_not_changed() {
|
||||
local option="$1"
|
||||
local default_value="$2"
|
||||
local option_value=$(tmux show-option -sv "$option")
|
||||
[ $option_value == $default_value ]
|
||||
[ "$option_value" == "$default_value" ]
|
||||
}
|
||||
|
||||
key_binding_not_set() {
|
||||
@ -30,6 +41,17 @@ key_binding_not_set() {
|
||||
fi
|
||||
}
|
||||
|
||||
key_binding_not_changed() {
|
||||
local key="$1"
|
||||
local default_value="$2"
|
||||
if $(tmux list-keys | grep -q "bind-key[[:space:]]\+${key}[[:space:]]\+${default_value}"); then
|
||||
# key still has the default binding
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
# OPTIONS
|
||||
|
||||
@ -39,12 +61,6 @@ main() {
|
||||
# enable utf8 in tmux status-left and status-right
|
||||
tmux set-option -g status-utf8 on
|
||||
|
||||
# set Ctrl-a as Tmux prefix
|
||||
if option_value_not_changed "prefix" "C-b"; then
|
||||
tmux set-option -g prefix C-a
|
||||
tmux unbind-key C-b
|
||||
fi
|
||||
|
||||
# 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
|
||||
@ -67,7 +83,7 @@ main() {
|
||||
|
||||
# required (only) on OS X
|
||||
if is_osx && option_value_not_changed "default-command" ""; then
|
||||
tmux set-option -g default-command "reattach-to-user-namespace -l bash"
|
||||
tmux set-option -g default-command "reattach-to-user-namespace -l $SHELL"
|
||||
fi
|
||||
|
||||
# upgrade $TERM
|
||||
@ -86,14 +102,24 @@ main() {
|
||||
|
||||
# DEFAULT KEY BINDINGS
|
||||
|
||||
# Ctrl-a + a send `Ctrl-a` to the shell
|
||||
if key_binding_not_set "a"; then
|
||||
tmux bind-key a send-prefix
|
||||
local prefix="$(prefix)"
|
||||
local prefix_without_ctrl="$(prefix_without_ctrl)"
|
||||
|
||||
# if C-b is not prefix
|
||||
if [ $prefix != "C-b" ]; then
|
||||
# unbind obsolte default binding
|
||||
if key_binding_not_changed "C-b" "send-prefix"; then
|
||||
tmux unbind-key C-b
|
||||
fi
|
||||
|
||||
# pressing `prefix + prefix` sends <prefix> to the shell
|
||||
tmux bind-key "$prefix" send-prefix
|
||||
fi
|
||||
|
||||
# Ctrl-a + Ctrl-a switch between alternate windows
|
||||
if key_binding_not_set "C-a"; then
|
||||
tmux bind-key C-a last-window
|
||||
# If Ctrl-a is prefix then `Ctrl-a + a` switches between alternate windows.
|
||||
# Works for any prefix character.
|
||||
if key_binding_not_set "$prefix_without_ctrl"; then
|
||||
tmux bind-key "$prefix_without_ctrl" last-window
|
||||
fi
|
||||
|
||||
# easier switching between next/prev window
|
||||
|
Reference in New Issue
Block a user