Skip to content

Instantly share code, notes, and snippets.

@vinoski
Last active September 13, 2016 12:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinoski/8867497 to your computer and use it in GitHub Desktop.
Save vinoski/8867497 to your computer and use it in GitHub Desktop.
Auto-generate bash functions for selecting kerl-installed Erlang versions. Functions are named based on the kerl-installed versions; for example, if you have R16B03 installed as r16b03, your shell will have a function named r16b03 for selecting that version. If you install a new version, run kerl_gen in your shell to regenerate the version selec…
export MYKERLVSN=''
no_kerl()
{
kerl_deactivate
unset _KERL_SAVED_AGNER_BIN _KERL_SAVED_AGNER_EXACT_PREFIX _KERL_SAVED_REBAR_PLT_DIR AGNER_BIN AGNER_EXACT_PREFIX
MYKERLVSN=''
}
kerl_gen()
{
for k in `ls /usr/local/var/kerl`; do
k2=${k/-/_}
eval $(echo "$k2() { . /usr/local/var/kerl/$k/activate; MYKERLVSN=$k; }")
done
}
kerl_gen
which_kerl()
{
[[ -n $MYKERLVSN ]] && printf ' (%s)' $MYKERLVSN
}
@vinoski
Copy link
Author

vinoski commented Feb 7, 2014

You can call which_gen in your bash prompt to have it display which kerl version is currently selected:

export PS1='$(which_kerl)\$ '

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