diffstore/completion/diffstore.bash
2023-02-22 15:22:49 +01:00

36 lines
782 B
Bash

#/usr/bin/env bash
_diffstore_completion()
{
local _cw2=(init list add store get clean config)
local _cw2_val=(get)
local _config_
local cur=$2
local N=0
local j I
local dir
local WORDS=()
COMPREPLY=()
if [ $COMP_CWORD -eq 1 ] ; then
_filedir -d
elif [ $COMP_CWORD -eq 2 ] ; then
WORDS=("${_cw2[@]}")
elif { [ "$COMP_CWORD" -eq "3" ] && echo "${_cw2_val[*]}" | grep -qw -- "${COMP_WORDS[2]}" ; } ; then
N=0
while read -r I ; do
WORDS+=("$I")
done < <($1 "${COMP_WORDS[1]}" list basic)
fi
N=0
if [ -n "$cur" ] ; then
for I in "${WORDS[@]}" ; do
[ "$I" != "${I#"$cur"}" ] && COMPREPLY[N++]=$I
done
else
COMPREPLY=("${WORDS[@]}")
fi
}
complete -o nospace -F _diffstore_completion -o dirnames diffstore