From e2187b2d23129d154e5a1a03018829f22e5e7a87 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sat, 22 Feb 2020 11:44:31 +1300 Subject: [PATCH 1/2] fix(completion): support scripts with `:` & `-` characters --- bin/completion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/completion.sh b/bin/completion.sh index 3589b6c..4aeb87d 100644 --- a/bin/completion.sh +++ b/bin/completion.sh @@ -11,7 +11,7 @@ function _nrun_completion() { local cur tasks cur=${COMP_WORDS[COMP_CWORD]} # The sed command strips terminal escape sequences. - tasks=$(nrun | grep '^ [a-zA-Z0-9]*$' | awk '{print $1}') + tasks=$(nrun | grep '^ [a-zA-Z0-9:-]*$' | awk '{print $1}') if [ $COMP_CWORD -eq 1 ]; then # Task name completion for first argument. COMPREPLY=( $(compgen -W "$tasks" "$cur") ) From a07b8f7edc5fb38120e5278c842f7455f9352d6e Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sat, 22 Feb 2020 12:37:17 +1300 Subject: [PATCH 2/2] fix(completion): trim colons properly --- bin/completion.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/completion.sh b/bin/completion.sh index 4aeb87d..4c84851 100644 --- a/bin/completion.sh +++ b/bin/completion.sh @@ -9,15 +9,15 @@ function _nrun_completion() { local cur tasks - cur=${COMP_WORDS[COMP_CWORD]} + _get_comp_words_by_ref -n : cur # The sed command strips terminal escape sequences. tasks=$(nrun | grep '^ [a-zA-Z0-9:-]*$' | awk '{print $1}') - if [ $COMP_CWORD -eq 1 ]; then + if [[ $COMP_LINE =~ ^${COMP_WORDS[0]}\ [^\ ]+\ ]]; then + COMPREPLY=( $(compgen -f "$cur") ) + else # Task name completion for first argument. COMPREPLY=( $(compgen -W "$tasks" "$cur") ) - else - # File name completion for other arguments. - COMPREPLY=( $(compgen -f "$cur") ) + __ltrim_colon_completions "$cur" fi } complete -F _nrun_completion nrun