From 4d8ac94fd96471300f8f90a8b297acb30da1dd57 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sat, 19 May 2018 20:03:19 +0000 Subject: [PATCH] renamed cheat client to cht.sh: bash completion --- share/bash_completion.txt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/share/bash_completion.txt b/share/bash_completion.txt index 3724760..4a9ae4a 100644 --- a/share/bash_completion.txt +++ b/share/bash_completion.txt @@ -1,18 +1,17 @@ -_cheatsh_complete_curl() +_cht_complete() { local cur prev opts _get_comp_words_by_ref -n : cur COMPREPLY=() - #cur="${COMP_WORDS[COMP_CWORD]}" + cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="$(curl -s cheat.sh/:list | sed s@^@cheat.sh/@)" + opts="$(curl -s cheat.sh/:list)" - if [[ ${cur} == cheat.sh/* ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - __ltrim_colon_completions "$cur" - return 0 + if [ ${COMP_CWORD} = 1 ]; then + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + __ltrim_colon_completions "$cur" fi + return 0 } -complete -F _cheatsh_complete_curl curl - +complete -F _cht_complete cht.sh