Skip to content

Instantly share code, notes, and snippets.

@timcharper
Created April 15, 2010 18:06
Show Gist options
  • Save timcharper/367421 to your computer and use it in GitHub Desktop.
Save timcharper/367421 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link

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