From 534c80f9ce1a0a67cd7f52eeae7b5026338a8f8f Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Fri, 10 Jun 2022 16:29:21 -0700 Subject: [PATCH] [direnv] fix for chruby path shenanigans --- .config/direnv/direnvrc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.config/direnv/direnvrc b/.config/direnv/direnvrc index e176b85..d324791 100644 --- a/.config/direnv/direnvrc +++ b/.config/direnv/direnvrc @@ -1,10 +1,21 @@ -bundle() { - PATH_add .bundle/bin - export GEM_HOME="`pwd`/.bundle" -} +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 +}