Skip to content

Instantly share code, notes, and snippets.

@davesque
Created October 25, 2012 18:15
Show Gist options
  • Save davesque/3954437 to your computer and use it in GitHub Desktop.
Save davesque/3954437 to your computer and use it in GitHub Desktop.
Bash and zshell completion for d.sh
# 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