Created
November 5, 2015 13:22
-
-
Save smblott-github/59c797524cd08170234f to your computer and use it in GitHub Desktop.
Rudimentary zsh completion for odeke-em/drive (a Google Drive utility)
This file contains hidden or 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
#compdef drive drive-google | |
local cmnd desc | |
if [[ $CURRENT == 2 ]] | |
then | |
local -a options | |
drive | | |
grep '^ [a-z]' | | |
while read cmnd desc | |
do | |
options+=( "$cmnd""[$desc]" ) | |
done | |
_values 'commands' $options | |
elif (( 2 < $CURRENT )) | |
then | |
# Argument completion. | |
local -a options | |
drive $words[2] -h 2>&1 1> /dev/null | | |
grep '^ -[a-z]' | | |
sed 's/: / /; s/=""/=/' | | |
while read cmnd desc | |
do | |
options+=( "$cmnd""[$desc]" ) | |
done | |
if (( 0 < $#options )) | |
then | |
_values 'options' $options | |
fi | |
# File/directory completion. | |
case $words[2] in | |
# These don't take file arguments. | |
'about' ) true ;; | |
'deinit' ) true ;; | |
'emptytrash' ) true ;; | |
'features' ) true ;; | |
'help' ) true ;; | |
'init' ) true ;; | |
'quota' ) true ;; | |
'version' ) true ;; | |
# Everything else does (I think). | |
* ) _path_files -f ;; | |
esac | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how can i use it?