Skip to content

Commit 0c1ee0e

Browse files
committed
Escape backslashes in key when grepping for keybindings
1 parent e91b178 commit 0c1ee0e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sensible.tmux

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ command_exists() {
1919
type "$command" >/dev/null 2>&1
2020
}
2121

22+
escape_for_regex() {
23+
local inp="$1"
24+
echo $inp | sed 's/\\/\\\\/g'
25+
}
26+
2227
# returns prefix key, e.g. 'C-a'
2328
prefix() {
2429
tmux show-option -gv prefix
@@ -45,7 +50,7 @@ server_option_value_not_changed() {
4550
}
4651

4752
key_binding_not_set() {
48-
local key="$1"
53+
local key=$(escape_for_regex "$1")
4954
if $(tmux list-keys | grep -q "${KEY_BINDING_REGEX}${key}[[:space:]]"); then
5055
return 1
5156
else
@@ -54,8 +59,8 @@ key_binding_not_set() {
5459
}
5560

5661
key_binding_not_changed() {
57-
local key="$1"
58-
local default_value="$2"
62+
local key=$(escape_for_regex "$1")
63+
local default_value=$(escape_for_regex "$2")
5964
if $(tmux list-keys | grep -q "${KEY_BINDING_REGEX}${key}[[:space:]]\+${default_value}"); then
6065
# key still has the default binding
6166
return 0

0 commit comments

Comments
 (0)