Last active
December 1, 2018 15:59
-
-
Save OldDragon2A/46768106871ed14f085d4131c2521cf0 to your computer and use it in GitHub Desktop.
Bash Completion for Drive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_drive() | |
{ | |
COMPREPLY=() | |
local cur prev cmd cmds files flags | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
pre="${COMP_WORDS[COMP_CWORD-1]}" | |
cmds="about clashes copy cp deinit del delete diff du edit-desc edit-description emptytrash features file-id help id index init issue list ls md5sum move mv new open pub pull push qr quota rename report repor | |
files="del delete diff edit-desc edit-description file-id id new open pub pull push rename share star stat unpub unshare untrash url" | |
if [ $COMP_CWORD -eq 1 ]; then | |
COMPREPLY=($(compgen -W "${cmds}" -- "${cur}")) | |
return | |
fi | |
cmd="${COMP_WORDS[1]}" | |
case "${cmd}" in | |
about) flags="-features -filesize -quiet -quota";; | |
clashes) flags="-depth -fix -hidden -id -list";; | |
cp|copy) flags="-id -quiet -recursive";; | |
deinit) flags="-no-prompt";; | |
del|delete) flags="-hidden -id -matches -no-prompt -quiet";; | |
diff) flags="-base-local -depth -hidden -ignore-checksum -ignore-conflict -ignore-name-clashes -quiet -recursive -skip-content-check -u";; | |
du) flags="-depth -directories -exact-owner -exact-title -files -hidden -id -long -match-mime -match-owner -matches -no-prompt -owners -pagesize -quiet -recursive -shared -skip-mime | |
edit-desc|edit-description) flags="-description -id -piped";; | |
emptytrash) flags="-no-prompt -quiet";; | |
file-id|id) flags="-depth -hidden";; | |
index) flags="-all-ops -exclude-ops -force -hidden -id -ignore-checksum -ignore-conflict -ignore-name-clashes -matches -no-clobber -no-prompt -prune -quiet -recursive -skip-mime";; | |
issue|report|report-issue) flags="-body -piped -title";; | |
list|ls) flags="-depth -directories -exact-owner -exact-title -files -hidden -id -long -match-mime -match-owner -matches -no-prompt -owners -pagesize -quiet -recursive -shared -skip-mime | |
md5sum) flags="-depth -hidden -id -quiet -recursive";; | |
move|mv) flags="-id -quiet";; | |
new) flags="-folder -mime-key";; | |
open) flags="-file-browser -id -web-browser";; | |
pub) flags="-hidden -id -quiet";; | |
pull) flags="-all -decryption-password -depth -desktop-links -directories -exclude-ops -explicitly-export -export -exports-dir -files -fix-clashes -force -hidden -id -ignore-checksum - | |
push) flags="-coerced-mime -convert -depth -destination -directories -encryption-password -exclude-ops -files -fix-clashes -force -hidden -ignore-checksum -ignore-conflict -ignore-name | |
qr) flags="-address -id -verbose";; | |
rename) flags="-force -id -local -quiet -remote";; | |
share) flags="-emails -id -message -no-prompt -notify -quiet -role -type -verbose -with-link";; | |
star) flags="-id -no-prompt -quiet";; | |
stat) flags="-depth -hidden -id -md5sum -quiet -recursive";; | |
touch) flags="-depth -duration -format -hidden -id -matches -quiet -recursive -time -verbose";; | |
trash) flags="-hidden -id -matches -quiet";; | |
unpub) flags="-hidden -id -quiet";; | |
unshare) flags="-emails -id -no-prompt -quiet -role -type -verbose";; | |
unstar) flags="-id -no-prompt -quiet";; | |
untrash) flags="-hidden -id -matches -quiet";; | |
url) flags="-id";; | |
esac | |
if [ -n "${flags}" ]; then | |
for w in ${COMP_WORDS[@]}; do | |
for o in ${flags[@]}; do | |
if [[ $w == $o ]]; then flags=( "${flags[@]/$o}" ); fi | |
done | |
done | |
fi | |
if [[ "${cur}" == -* ]]; then | |
COMPREPLY=($(compgen -W "${flags}" -- "${cur}")) | |
elif [[ " ${files[@]} " =~ " $cmd " ]]; then | |
COMPREPLY=($(compgen -df -- "${cur}")) | |
else | |
COMPREPLY=($(compgen -W "${flags}" -- "${cur}")) | |
fi | |
} | |
complete -F _drive drive |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Every line with more than 208 characters is cut off