Created
October 25, 2012 18:15
-
-
Save davesque/3954437 to your computer and use it in GitHub Desktop.
Bash and zshell completion for d.sh
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
# For bash | |
function _d { | |
COMPREPLY=(); | |
cur="${COMP_WORDS[COMP_CWORD]}"; | |
if [ $COMP_CWORD -eq 1 ]; then | |
opts=$(find $WORKON_HOME -maxdepth 1 -type d | awk -F/ '{ if ( $NF ~ /^[^.]/ ) print $NF }'); | |
COMPREPLY=( $(compgen -W "$opts" -- $cur) ); | |
fi | |
} | |
complete -F _d d | |
# For zshell | |
function _d { | |
reply=($(find $WORKON_HOME -maxdepth 1 -type d | awk -F/ '{ if ( $NF ~ /^[^.]/ ) print $NF }')) | |
} | |
compctl -K _d d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment