buku/auto-completion/bash/buku-completion.bash
2016-05-29 14:12:50 +05:30

32 lines
897 B
Bash

#
# Bash completion definition for buku.
#
# Author:
# Arun Prakash Jana <engineerarun@gmail.com>
#
_buku () {
COMPREPLY=()
local IFS=$' \n'
local cur=$2 prev=$3
local -a opts opts_with_args
opts=(-a --add -c --comment -d --delete -h --help -i --import -k --unlock
-l --lock --merge --noprompt -o --open -p --print -r --replace -s --sany
-S --sall --st --stag --tag -t --title -u --update --url)
opts_with_arg=(-a --add -i --import --merge -o --open -r --replace -s --sany -S --sall)
# Do not complete non option names
[[ $cur == -* ]] || return 1
# Do not complete when the previous arg is an option expecting an argument
for opt in "${opts_with_arg[@]}"; do
[[ $opt == $prev ]] && return 1
done
# Complete option names
COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
return 0
}
complete -F _buku buku