_fossil() { local cur prev opts #Var used by BASH COMPREPLY=() #word we are trying to complete cur="${COMP_WORDS[COMP_CWORD]}" #word before the one we're trying to complete prev="${COMP_WORDS[COMP_CWORD-1]}" #list of word that fossil know opts="add addremove all annotate bisect branch cat changes checkout " opts="$opts ci clean clone close co commit delete diff export extras " opts="$opts finfo gdiff help import info init ls merge mv new open " opts="$opts pull push rebuild remote-url revert rm settings sqlite3 " opts="$opts stash status sync tag timeline ui undo unset update version" case "${prev}" in add) opts="--dotfiles --ignore" ;; addremove) opts="--dotfiles --ignore --test" ;; all) opts="list ls pull push rebuild sync" ;; annotate) opts="--limit --log --filevers" ;; bisect) opts="bad good next options reset vlist" ;; branch) opts="list ls -R --repository" ;; merge) opts="--nochange -n --force -f --detail" esac compopt -o filenames COMPREPLY=($(compgen -fW "${opts}" -- "${cur}") \ $(compgen -d -- "$cur")) } complete -F _fossil fossil