mirror of
https://github.com/tmux-plugins/tmux-sensible.git
synced 2024-11-24 00:48:46 +00:00
Escape backslashes in key when grepping for keybindings
This commit is contained in:
parent
e91b178ff8
commit
0c1ee0e224
@ -19,6 +19,11 @@ command_exists() {
|
|||||||
type "$command" >/dev/null 2>&1
|
type "$command" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
escape_for_regex() {
|
||||||
|
local inp="$1"
|
||||||
|
echo $inp | sed 's/\\/\\\\/g'
|
||||||
|
}
|
||||||
|
|
||||||
# returns prefix key, e.g. 'C-a'
|
# returns prefix key, e.g. 'C-a'
|
||||||
prefix() {
|
prefix() {
|
||||||
tmux show-option -gv prefix
|
tmux show-option -gv prefix
|
||||||
@ -45,7 +50,7 @@ server_option_value_not_changed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
key_binding_not_set() {
|
key_binding_not_set() {
|
||||||
local key="$1"
|
local key=$(escape_for_regex "$1")
|
||||||
if $(tmux list-keys | grep -q "${KEY_BINDING_REGEX}${key}[[:space:]]"); then
|
if $(tmux list-keys | grep -q "${KEY_BINDING_REGEX}${key}[[:space:]]"); then
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
@ -54,8 +59,8 @@ key_binding_not_set() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
key_binding_not_changed() {
|
key_binding_not_changed() {
|
||||||
local key="$1"
|
local key=$(escape_for_regex "$1")
|
||||||
local default_value="$2"
|
local default_value=$(escape_for_regex "$2")
|
||||||
if $(tmux list-keys | grep -q "${KEY_BINDING_REGEX}${key}[[:space:]]\+${default_value}"); then
|
if $(tmux list-keys | grep -q "${KEY_BINDING_REGEX}${key}[[:space:]]\+${default_value}"); then
|
||||||
# key still has the default binding
|
# key still has the default binding
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user