Skip to content

Instantly share code, notes, and snippets.

@smblott-github
Created November 5, 2015 13:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smblott-github/59c797524cd08170234f to your computer and use it in GitHub Desktop.
Save smblott-github/59c797524cd08170234f to your computer and use it in GitHub Desktop.
Rudimentary zsh completion for odeke-em/drive (a Google Drive utility)
#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
@andre4nap
Copy link

how can i use it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment