Skip to content

Commit

Permalink
feat: Add scripts to set DOTNET_ROOT env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
hensou committed Apr 25, 2022
1 parent 65b5b7a commit 45074c0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions set-dotnet-env.bash
@@ -0,0 +1,15 @@
asdf_update_dotnet_home() {
local dotnet_path
dotnet_path="$(asdf which dotnet)"
if [[ -n "${dotnet_path}" ]]; then
export DOTNET_ROOT
DOTNET_ROOT="$(dirname "$(realpath "${dotnet_path}")")"
fi
}

prompt_command() {
asdf_update_dotnet_home
}

export PROMPT_COMMAND="${PROMPT_COMMAND:+${PROMPT_COMMAND}; prompt_command}"
export PROMPT_COMMAND="${PROMPT_COMMAND:-prompt_command}"
11 changes: 11 additions & 0 deletions set-dotnet-env.zsh
@@ -0,0 +1,11 @@
asdf_update_dotnet_home() {
local dotnet_path
dotnet_path="$(asdf which dotnet)"
if [[ -n "${dotnet_path}" ]]; then
export DOTNET_ROOT
DOTNET_ROOT="$(dirname "$(realpath "${dotnet_path}")")"
fi
}

autoload -U add-zsh-hook
add-zsh-hook precmd asdf_update_dotnet_home

0 comments on commit 45074c0

Please sign in to comment.