Bash filename completion and more!

This commit is contained in:
Username404-59 2021-02-27 14:19:45 +01:00
parent 9c31ac48e5
commit b6f2c79d5c
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 11 additions and 2 deletions

View File

@ -1,15 +1,24 @@
# Bash autocomplete script for yerbacon
function YCompReply() { mapfile -t COMPREPLY <<< "$1"; }
_ybconAutoComplete() {
compopt +o default
local current previous options
COMPREPLY=()
current="${COMP_WORDS[COMP_CWORD]}"
previous="${COMP_WORDS[COMP_CWORD-1]}"
options='-h -p --help --printresult --version'
if [[ "${current}" == -* ]]; then
mapfile -t COMPREPLY <<< "$(compgen -W "$options" -- "$current") "
YCompReply "$(compgen -W "$options" -- "$current")"
return 0
else
case "${previous}" in
-h | --help | --version )
exit 0 ;;
esac
complete -f -o plusdirs -X '!*.ybcon' ybcon
fi
}
complete -o nospace -F _ybconAutoComplete ybcon
complete -F _ybconAutoComplete ybcon