diff options
Diffstat (limited to 'package/.sdb-completion.bash')
-rw-r--r-- | package/.sdb-completion.bash | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/package/.sdb-completion.bash b/package/.sdb-completion.bash index d58fc0b..7623a06 100644 --- a/package/.sdb-completion.bash +++ b/package/.sdb-completion.bash @@ -1,10 +1,13 @@ _sdb() { - #sdb path is defined in PATH environment variable - COMPREPLY=() + #check if the input is local or remote path. + INPUT_IS_PATH=0 + #sdb path is defined in PATH environment variable SDB_PATH=$(eval eval echo \$\{COMP_WORDS\[0\]\}) + COMPREPLY=() + if [ ! -f ${SDB_PATH} ]; then return 0; @@ -14,6 +17,13 @@ _sdb() ARGS="autocomplete,${COMP_CWORD}" local IFS=$',' + + if [ -n ${COMP_WORDS[1]} ]; then + if [ "${COMP_WORDS[1]}" == "push" ] || [ "${COMP_WORDS[1]}" == "pull" ]; then + INPUT_IS_PATH=1 + fi + fi + for ((i=1; i < $((${COMP_CWORD} + 1)) ; i++)) do #processing for echo options @@ -30,9 +40,12 @@ _sdb() next=($("${SDB_PATH}" ${ARGS})) local IFS=$'\n' COMPREPLY=(${next}) -# COMPREPLY=($(compgen -W "${next}" -- ${cur})) + + if [ $INPUT_IS_PATH == 0 ]; then + COMPREPLY=( "${COMPREPLY[@]/%/ }" ) #add trailing space to each + fi return 0 } -complete -o filenames -F _sdb sdb +complete -o nospace -F _sdb sdb |