diff --git a/functions/_pisces_bind_pair.fish b/functions/_pisces_bind_pair.fish index 093a1ab..a2ba522 100644 --- a/functions/_pisces_bind_pair.fish +++ b/functions/_pisces_bind_pair.fish @@ -1,4 +1,7 @@ -function _pisces_bind_pair -a left right -d "Creates bindings for the given pair: autoclose and remove empty" +function _pisces_bind_pair -a mode left right -d "Creates bindings for the given pair: autoclose and remove empty" + + test -z $mode + and set mode default set l $left set r $right @@ -8,10 +11,10 @@ function _pisces_bind_pair -a left right -d "Creates bindings for the given pair if [ $left = $right ] - bind $r "_pisces_skip $right; or _pisces_append $right" + bind -M $mode $r "_pisces_skip $right; or _pisces_append $right" else # if $some_special_setting - bind $l "commandline -i -- $left; and _pisces_append $right" - bind $r "_pisces_skip $right" + bind -M $mode $l "commandline -i -- $left; and _pisces_append $right" + bind -M $mode $r "_pisces_skip $right" end end diff --git a/key_bindings.fish b/key_bindings.fish index badf58f..8cf5a8a 100644 --- a/key_bindings.fish +++ b/key_bindings.fish @@ -1,17 +1,22 @@ function key_bindings + set -l _pisces_bind_mode default + if [ "$fish_key_bindings" = 'fish_vi_key_bindings' ] + set _pisces_bind_mode insert + end + set -q pisces_pairs or set -U pisces_pairs '(,)' '[,]' '{,}' '","' "','" for pair in $pisces_pairs - _pisces_bind_pair (string split -- ',' $pair) + _pisces_bind_pair $_pisces_bind_mode (string split -- ',' $pair) end # normal backspace, also known as \010 or ^H: - bind \b _pisces_backspace + bind -M $_pisces_bind_mode \b _pisces_backspace # Terminal.app sends DEL code on ⌫: - bind \177 _pisces_backspace + bind -M $_pisces_bind_mode \177 _pisces_backspace # overrides TAB to provide completion of vars before a closing '"' - bind \t _pisces_complete + bind -M $_pisces_bind_mode \t _pisces_complete end