mirror of
https://github.com/tmux-plugins/tmux-sensible.git
synced 2024-11-24 00:48:46 +00:00
Do not force prefix to C-a
Assuming no one uses C-b as the default prefix is a wrong assumption. Instead of making any assumption about the prefix, we're "building" on top of whatever the user has set. The following key-bindings will be set if prefix is set to C-a: - `C-a + C-a` - sends prefix character - `C-a + a` - switches to the last window Likewise, if C-b is prefix, then the additional bindings will be `C-b + C-b` and `C-b + b`. Closes #1
This commit is contained in:
parent
47df9983a9
commit
89a51c86e3
@ -3,6 +3,7 @@
|
|||||||
### master
|
### master
|
||||||
- bugfix: determine the default shell from the $SHELL env var on OS X
|
- bugfix: determine the default shell from the $SHELL env var on OS X
|
||||||
- set `mode-mouse on` by default
|
- set `mode-mouse on` by default
|
||||||
|
- do not make any decision about the prefix, just enhance it
|
||||||
|
|
||||||
### v1.0.0, 2014-07-30
|
### v1.0.0, 2014-07-30
|
||||||
- initial work on the plugin
|
- initial work on the plugin
|
||||||
|
@ -7,6 +7,17 @@ is_osx() {
|
|||||||
[ "$platform" == "Darwin" ]
|
[ "$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() {
|
option_value_not_changed() {
|
||||||
local option="$1"
|
local option="$1"
|
||||||
local default_value="$2"
|
local default_value="$2"
|
||||||
@ -39,12 +50,6 @@ main() {
|
|||||||
# enable utf8 in tmux status-left and status-right
|
# enable utf8 in tmux status-left and status-right
|
||||||
tmux set-option -g status-utf8 on
|
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)
|
# address vim mode switching delay (http://superuser.com/a/252717/65504)
|
||||||
if server_option_value_not_changed "escape-time" "500"; then
|
if server_option_value_not_changed "escape-time" "500"; then
|
||||||
tmux set-option -s escape-time 0
|
tmux set-option -s escape-time 0
|
||||||
@ -87,14 +92,22 @@ main() {
|
|||||||
|
|
||||||
# DEFAULT KEY BINDINGS
|
# DEFAULT KEY BINDINGS
|
||||||
|
|
||||||
# Ctrl-a + a send `Ctrl-a` to the shell
|
local prefix="$(prefix)"
|
||||||
if key_binding_not_set "a"; then
|
local prefix_without_ctrl="$(prefix_without_ctrl)"
|
||||||
tmux bind-key a send-prefix
|
|
||||||
|
# if C-b is not prefix
|
||||||
|
if [ $prefix != "C-b" ]; then
|
||||||
|
# unbind obsolte default binding
|
||||||
|
tmux unbind-key C-b
|
||||||
|
|
||||||
|
# pressing `prefix + prefix` sends <prefix> to the shell
|
||||||
|
tmux bind-key "$prefix" send-prefix
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ctrl-a + Ctrl-a switch between alternate windows
|
# If Ctrl-a is prefix then `Ctrl-a + a` switches between alternate windows.
|
||||||
if key_binding_not_set "C-a"; then
|
# Works for any prefix character.
|
||||||
tmux bind-key C-a last-window
|
if key_binding_not_set "$prefix_without_ctrl"; then
|
||||||
|
tmux bind-key "$prefix_without_ctrl" last-window
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# easier switching between next/prev window
|
# easier switching between next/prev window
|
||||||
|
Loading…
Reference in New Issue
Block a user