Skip to content

Instantly share code, notes, and snippets.

@1stvamp
Last active March 17, 2021 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1stvamp/342030ba92a80597b9a39cc15be33f01 to your computer and use it in GitHub Desktop.
Save 1stvamp/342030ba92a80597b9a39cc15be33f01 to your computer and use it in GitHub Desktop.
rbenv/jenv shims for use with asdf, specifically for exec support
#!/usr/bin/env bash
set -e
if [ "$#" -gt 0 ] && [ "$1" = "shell" ]
then
shift
_SHIM_VERSION=${1:-$(asdf current ruby | awk '{print $1}')}
asdf sh-shell ruby "${_SHIM_VERSION}"
elif [ "$#" -gt 0 ] && [ "$1" = "version" ]
then
exec asdf --version
elif [ "$#" -gt 0 ] && [ "$1" = "init" ]
then
exit 0
else
exec asdf "$@"
fi
#!/usr/bin/env bash
set -e
if [ "$#" -gt 0 ] && [ "$1" = "exec" ]
then
shift
exec asdf exec "$@"
elif [ "$#" -gt 0 ] && [ "$1" = "versions" ]
then
asdf list ruby | sed 's/^ *//g'
elif [ "$#" -gt 0 ] && [ "$1" = "shell" ]
then
shift
_SHIM_VERSION=${1:-$(asdf current ruby | awk '{print $1}')}
_ASDF_DIR=$(dirname "$(dirname "$(which asdf)")")
# shellcheck disable=SC1091
source "${_ASDF_DIR}/asdf.sh"
asdf shell ruby "${_SHIM_VERSION}"
elif [ "$#" -gt 0 ] && [ "$1" = "version" ]
then
exec asdf --version
elif [ "$#" -gt 0 ] && [ "$1" = "init" ]
then
exit 0
else
command="$1"
shift
if [ "$1" = "--skip-existing" ]
then
shift
fi
exec asdf "${command}" ruby "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment