You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.4 KiB

# source $HOME/.nix-profile/share/nix-direnv/direnvrc
source `brew --prefix`/share/chruby/chruby.sh
layout_k8s() {
if [ $commands[kubectl] ]; then
source <(kubectl completion zsh)
fi
}
# https://github.com/direnv/direnv/issues/98#issuecomment-33677881
use_ruby() {
local ver=$1
if [[ -z $ver ]] && [[ -f .ruby-version ]]; then
ver=$(cat .ruby-version)
fi
if [[ -z $ver ]]; then
echo Unknown ruby version
exit 1
fi
chruby $ver
layout ruby
# For some reason, the PATH order is unstable and sometimes Ruby's
# bin directory is in front of the direnv one, so force the direnv
# bin directory to take precedence
PATH_add ./.direnv/bin
}
# https://github.com/direnv/direnv/wiki/Python/#poetry
layout_poetry() {
PYPROJECT_TOML="${PYPROJECT_TOML:-pyproject.toml}"
if [[ ! -f "$PYPROJECT_TOML" ]]; then
log_status "No pyproject.toml found. Executing \`poetry init\` to create a \`$PYPROJECT_TOML\` first."
poetry init
fi
if [[ -d ".venv" ]]; then
VIRTUAL_ENV="$(pwd)/.venv"
else
VIRTUAL_ENV=$(poetry env info --path 2>/dev/null ; true)
fi
if [[ -z $VIRTUAL_ENV || ! -d $VIRTUAL_ENV ]]; then
log_status "No virtual environment exists. Executing \`poetry install\` to create one."
poetry install
VIRTUAL_ENV=$(poetry env info --path)
fi
PATH_add "$VIRTUAL_ENV/bin"
export POETRY_ACTIVE=1
export VIRTUAL_ENV
}