Skip to content

Instantly share code, notes, and snippets.

@wess
Created August 28, 2023 15:41
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 wess/197c2719265321c67dee2835c8ae97b6 to your computer and use it in GitHub Desktop.
Save wess/197c2719265321c67dee2835c8ae97b6 to your computer and use it in GitHub Desktop.
# ~/.bashrc or ~/.zshrc
# Direnv setup
eval "$(direnv hook bash)" # or 'zsh' if you're using zsh
# Asdf setup (assuming you've set up asdf as per its documentation)
. $HOME/.asdf/asdf.sh
# Custom 'use' command for direnv
use_asdf() {
local tool_version
for tool_version in $(cat .tool-versions); do
local tool_name
tool_name=$(echo $tool_version | awk '{print $1}')
local version
version=$(echo $tool_version | awk '{print $2}')
asdf local $tool_name $version
done
}
# If the `.envrc` file has 'use asdf', it will run the above function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment