diff --git a/functions/__fisher_key_bindings_disable.fish b/functions/__fisher_key_bindings_disable.fish index 1e987fc..e5f3457 100644 --- a/functions/__fisher_key_bindings_disable.fish +++ b/functions/__fisher_key_bindings_disable.fish @@ -1,17 +1,11 @@ function __fisher_key_bindings_disable -a plugin user_key_bindings - fish_indent < $fisher_binds \ - | __fisher_key_bindings_undo $plugin \ - | source + fish_indent < $fisher_binds | __fisher_key_bindings_undo $plugin | source ^ /dev/null - __fisher_key_bindings_delete $plugin \ - > $fisher_binds.tmp \ - < $fisher_binds + __fisher_key_bindings_delete $plugin > $fisher_binds.tmp < $fisher_binds command mv -f $fisher_binds.tmp $fisher_binds if test ! -s $fisher_binds - debug "Remove fisherman key bindings '%s'" "$user_key_bindings" - sed -i.tmp '/__fisher_key_bindings/d' $user_key_bindings command rm -f $user_key_bindings.tmp end diff --git a/functions/__fisher_key_bindings_undo.fish b/functions/__fisher_key_bindings_undo.fish index d81f3e1..f59e817 100644 --- a/functions/__fisher_key_bindings_undo.fish +++ b/functions/__fisher_key_bindings_undo.fish @@ -1,3 +1,3 @@ function __fisher_key_bindings_undo -a plugin - sed -n "/##$plugin##/,/##$plugin##/{s/bind /bind -e /p;};" + sed -n "/##$plugin##/,/##$plugin##/{s/^ *bind /bind -e /p;};" end diff --git a/test/fixtures/key-bindings/fisher_key_bindings.fish b/test/fixtures/key-bindings/fisher_key_bindings.fish index f888dfc..bdd2547 100644 --- a/test/fixtures/key-bindings/fisher_key_bindings.fish +++ b/test/fixtures/key-bindings/fisher_key_bindings.fish @@ -1,6 +1,6 @@ ##foo## -echo bind foo +bind foo ##foo## ##bar## -echo bind bar +bind bar ##bar## diff --git a/test/key-bindings-disable.fish b/test/key-bindings-disable.fish index 5fceb6d..baa1c3e 100644 --- a/test/key-bindings-disable.fish +++ b/test/key-bindings-disable.fish @@ -7,6 +7,10 @@ function -S setup set -g fisher_binds $path/fisher_key_bindings.fish + function bind + printf "%s\n" "bind $argv" + end + for plugin in foo bar baz __fisher_key_bindings_disable $plugin $path/user_key_bindings.fish >> $path/key_bindings_log end @@ -14,6 +18,7 @@ end function -S teardown rm -rf $path + functions -e bind end test "$TESTNAME - Remove bindings from fisher key bindings file"