Do not unbind C-b if a user still uses it

Fixes #5
This commit is contained in:
Bruno Sutic 2014-08-30 22:44:37 +02:00
parent fa3e8b91ea
commit 4967aa0ce7
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
2 changed files with 16 additions and 1 deletions

View File

@ -6,6 +6,8 @@
- 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

View File

@ -41,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
@ -97,7 +108,9 @@ main() {
# 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