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
e1e49ceaff
commit
3308240929
4 changed files with 10 additions and 11 deletions
|
@ -1,17 +1,11 @@
|
||||||
function __fisher_key_bindings_disable -a plugin user_key_bindings
|
function __fisher_key_bindings_disable -a plugin user_key_bindings
|
||||||
fish_indent < $fisher_binds \
|
fish_indent < $fisher_binds | __fisher_key_bindings_undo $plugin | source ^ /dev/null
|
||||||
| __fisher_key_bindings_undo $plugin \
|
|
||||||
| source
|
|
||||||
|
|
||||||
__fisher_key_bindings_delete $plugin \
|
__fisher_key_bindings_delete $plugin > $fisher_binds.tmp < $fisher_binds
|
||||||
> $fisher_binds.tmp \
|
|
||||||
< $fisher_binds
|
|
||||||
|
|
||||||
command mv -f $fisher_binds.tmp $fisher_binds
|
command mv -f $fisher_binds.tmp $fisher_binds
|
||||||
|
|
||||||
if test ! -s $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
|
sed -i.tmp '/__fisher_key_bindings/d' $user_key_bindings
|
||||||
command rm -f $user_key_bindings.tmp
|
command rm -f $user_key_bindings.tmp
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
function __fisher_key_bindings_undo -a plugin
|
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
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
##foo##
|
##foo##
|
||||||
echo bind foo
|
bind foo
|
||||||
##foo##
|
##foo##
|
||||||
##bar##
|
##bar##
|
||||||
echo bind bar
|
bind bar
|
||||||
##bar##
|
##bar##
|
||||||
|
|
|
@ -7,6 +7,10 @@ function -S setup
|
||||||
|
|
||||||
set -g fisher_binds $path/fisher_key_bindings.fish
|
set -g fisher_binds $path/fisher_key_bindings.fish
|
||||||
|
|
||||||
|
function bind
|
||||||
|
printf "%s\n" "bind $argv"
|
||||||
|
end
|
||||||
|
|
||||||
for plugin in foo bar baz
|
for plugin in foo bar baz
|
||||||
__fisher_key_bindings_disable $plugin $path/user_key_bindings.fish >> $path/key_bindings_log
|
__fisher_key_bindings_disable $plugin $path/user_key_bindings.fish >> $path/key_bindings_log
|
||||||
end
|
end
|
||||||
|
@ -14,6 +18,7 @@ end
|
||||||
|
|
||||||
function -S teardown
|
function -S teardown
|
||||||
rm -rf $path
|
rm -rf $path
|
||||||
|
functions -e bind
|
||||||
end
|
end
|
||||||
|
|
||||||
test "$TESTNAME - Remove bindings from fisher key bindings file"
|
test "$TESTNAME - Remove bindings from fisher key bindings file"
|
||||||
|
|
Loading…
Reference in a new issue