Bash filename completion and more!
This commit is contained in:
parent
9c31ac48e5
commit
b6f2c79d5c
|
@ -1,15 +1,24 @@
|
||||||
# Bash autocomplete script for yerbacon
|
# Bash autocomplete script for yerbacon
|
||||||
|
|
||||||
|
function YCompReply() { mapfile -t COMPREPLY <<< "$1"; }
|
||||||
|
|
||||||
_ybconAutoComplete() {
|
_ybconAutoComplete() {
|
||||||
|
compopt +o default
|
||||||
local current previous options
|
local current previous options
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
current="${COMP_WORDS[COMP_CWORD]}"
|
current="${COMP_WORDS[COMP_CWORD]}"
|
||||||
previous="${COMP_WORDS[COMP_CWORD-1]}"
|
previous="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
options='-h -p --help --printresult --version'
|
options='-h -p --help --printresult --version'
|
||||||
if [[ "${current}" == -* ]]; then
|
if [[ "${current}" == -* ]]; then
|
||||||
mapfile -t COMPREPLY <<< "$(compgen -W "$options" -- "$current") "
|
YCompReply "$(compgen -W "$options" -- "$current")"
|
||||||
return 0
|
return 0
|
||||||
|
else
|
||||||
|
case "${previous}" in
|
||||||
|
-h | --help | --version )
|
||||||
|
exit 0 ;;
|
||||||
|
esac
|
||||||
|
complete -f -o plusdirs -X '!*.ybcon' ybcon
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
complete -o nospace -F _ybconAutoComplete ybcon
|
complete -F _ybconAutoComplete ybcon
|
Loading…
Reference in New Issue