Created
April 12, 2013 19:21
-
-
Save pigmonkey/5374436 to your computer and use it in GitHub Desktop.
Bash completion for ppl
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
_ppl() | |
{ | |
local cur prev opts nick_cmds base | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
# Complete options | |
opts="add age bday email init ls mutt mv name nick org phone post pull push remote rm shell show url version" | |
if [[ ${prev} == "ppl" ]]; then | |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) | |
return 0 | |
fi | |
# Complete nicknames | |
nick_cmds=([age]="" [bday]="" [email]="" [mv]="" [name]="" [nick]="" [org]="" [phone]="" [post]="" [rm]="" [show]="" [url]="") | |
if [[ $nick_cmds[${prev}] ]]; then | |
local nicknames=$(for x in `ppl nick | cut -d ':' -f 1`; do echo ${x} ; done ) | |
COMPREPLY=( $(compgen -W "${nicknames}" -- ${cur}) ) | |
return 0 | |
fi | |
} | |
complete -F _ppl ppl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment