Skip to content

Commit

Permalink
Add bash completion. See #75
Browse files Browse the repository at this point in the history
  • Loading branch information
svent committed Oct 13, 2016
1 parent bb4570c commit ae23dc9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions sift-completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
_sift()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"

if [[ ${cur} == -* ]] ; then
opts="$(sift --help | sift '\s+(--[\w-]+)(?:\s|=)' --replace '$1' --output-sep ' ')"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi

case "${prev}" in
-t|-T|--type|--no-type|--del-type)
types="$(sift --list-types | sift '^(\w+)\s+:' --replace '$1' --output-sep ' ')"
COMPREPLY=( $(compgen -W "${types}" -- ${cur}) )
return 0;;
esac

_filedir
return 0
}
complete -F _sift sift

0 comments on commit ae23dc9

Please sign in to comment.