Skip to content

Instantly share code, notes, and snippets.

@zaach
Created June 19, 2010 16:51
Show Gist options
  • Save zaach/445056 to your computer and use it in GitHub Desktop.
Save zaach/445056 to your computer and use it in GitHub Desktop.
Here's a quick and dirty bash_completion script. Paste this in a file named "google" in your /etc/bash_completion.d/ directory:
_google()
{
local cur prev commands options
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
commands="help picasa blogger youtube docs contacts calendar"
if [[ $COMP_CWORD -eq 1 ]] ; then
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
else
case "${prev}" in
help)
options='picasa blogger youtube docs contacts calendar'
;;
picasa)
options='get create list list-albums tag post delete'
;;
blogger)
options='post tag list delete'
;;
youtube)
options='post tag list delete'
;;
docs)
options='edit delete list upload get'
;;
contacts)
options='add list delete'
;;
calendar)
options='add list today delete'
;;
*)
COMPREPLY=( $(compgen -f ${cur}) )
return 0
;;
esac
COMPREPLY=( $(compgen -W "${options}" -- ${cur}) )
fi
return 0
}
complete -F _google google
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment