From bb357bf93b64821e3b8d57d0b14402e4189b205c Mon Sep 17 00:00:00 2001 From: Alexey Alekhin Date: Fri, 13 May 2016 22:10:30 +0200 Subject: [PATCH] Added function overriding TAB to provide completion of vars before a closing `"` (closes #1) --- functions/_pisces_tab.fish | 13 +++++++++++++ key_bindings.fish | 3 +++ uninstall.fish | 3 ++- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 functions/_pisces_tab.fish diff --git a/functions/_pisces_tab.fish b/functions/_pisces_tab.fish new file mode 100644 index 0000000..0c5fa25 --- /dev/null +++ b/functions/_pisces_tab.fish @@ -0,0 +1,13 @@ +function _pisces_complete -d "Invokes complete with modification for vars before a closing double quote" + + if commandline --paging-mode + down-or-search + else + set token (commandline -t) + # checking that the current token ends on a $var + '"' + if [ (string match -r '\$.*"$' "$token") ] + commandline -f delete-char # which is '"' + end + commandline -f complete + end +end diff --git a/key_bindings.fish b/key_bindings.fish index f7a4066..fa81081 100644 --- a/key_bindings.fish +++ b/key_bindings.fish @@ -11,4 +11,7 @@ function key_bindings bind \b _pisces_backspace # Terminal.app sends DEL code on ⌫: bind \177 _pisces_backspace + + # overrides TAB to provide completion of vars before a closing '"' + bind \t _pisces_complete end diff --git a/uninstall.fish b/uninstall.fish index a982448..c0fbf7b 100644 --- a/uninstall.fish +++ b/uninstall.fish @@ -4,7 +4,8 @@ for pair in $pisces_pairs end end -bind \b backward-delete-char +bind \b backward-delete-char bind \177 backward-delete-char +bind \t complete set -e pisces_pairs