Create a gist now

Instantly share code, notes, and snippets.

bash completion for leiningen
_lein_test()
{
local curw
COMPREPLY=()
curw=${COMP_WORDS[COMP_CWORD]}
if [ -d test ]; then
COMPREPLY=($(compgen -W '$(cd test; find * -name \*.clj | sed "s/.clj\$//" | sed "s/_/-/g" | sed "s|/|.|g")' -- $curw));
return 0
fi
}
_lein()
{
if [ $COMP_CWORD == 1 ]; then
curw=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "repl pom help install jar test deps uberjar clean compile version swank new" -- $curw) )
return 0
else
case ${COMP_WORDS[1]} in
test) _lein_test ;;
esac
fi
}
complete -F _lein -o default lein
@drewnoakes

Note that a (different) version of this file is available in the Leiningen repo:

https://github.com/technomancy/leiningen/blob/master/bash_completion.bash

Rename and copy that file as:

sudo cp ./bash_completion.bash /etc/bash_completion.d/lein
@theresiasnow

on mac os x
cp lein-completion.bash /usr/local/etc/bash_completion.d/lein

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