mirror of
https://github.com/jorgebucaran/fisher
synced 2024-10-09 09:36:53 +02:00
Make __fisher_key_bindings_undo smarter. Close #121.
Until now key_bindings.fish only allowed simple bind <args> staments and would fail for conditional statements, etc.
This commit is contained in:
parent
2f325c38ae
commit
34b880f6be
4 changed files with 10 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
##foo##
|
||||
echo bind foo
|
||||
bind foo
|
||||
##foo##
|
||||
##bar##
|
||||
echo bind bar
|
||||
bind bar
|
||||
##bar##
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue