diff --git a/extras/completion/ctt b/extras/completion/ctt new file mode 100644 index 0000000..e8745af --- /dev/null +++ b/extras/completion/ctt @@ -0,0 +1,20 @@ +_ctt() +{ + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + comms="listproject track report" + opts="-h --help -d --debug -v --verbose" + cmdopts="--sd --start --ed --end -a --all -e --regexp -i --ignorecase -f --format" + case "${prev}" in + track|report) + local projects=$(for p in ~/.ctt/*; do basename "$p"; done ) + COMPREPLY=( $(compgen -W "${projects} ${opts} ${cmdopts}" -- ${cur}) ) + return 0 + ;; + esac + COMPREPLY=( $(compgen -W "${comms} ${opts}" -- ${cur}) ) + return 0 +} +complete -F _ctt ctt diff --git a/setup.py b/setup.py index 2e05938..38f1edf 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,9 @@ setup(name='ctt', packages=['lib/ctt', ], scripts=['scripts/ctt'], + data_files=[ + ('/etc/bash_completion.d/', ['extras/completion/ctt']), + ], zip_safe=True, classifiers=[ 'Environment :: Console',