1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-30 09:40:09 +00:00
ohmyzsh/plugins/goenv/goenv.plugin.zsh
2021-07-08 01:26:18 +00:00

42 lines
985 B
Bash

# This plugin loads goenv into the current shell.
# Load goenv only if command not already available
if command -v goenv &> /dev/null && [[ "$(uname -r)" != *icrosoft* ]]; then
FOUND_GOENV=1
else
FOUND_GOENV=0
fi
if [[ $FOUND_GOENV -ne 1 ]]; then
goenvdirs=("$HOME/.goenv" "/usr/local/goenv" "/opt/goenv" "/usr/local/opt/goenv")
for dir in $goenvdirs; do
if [[ -d $dir/bin ]]; then
export PATH="$PATH:$dir/bin"
FOUND_GOENV=1
break
fi
done
fi
if [[ $FOUND_GOENV -ne 1 ]]; then
if (( $+commands[brew] )) && dir=$(brew --prefix goenv 2>/dev/null); then
if [[ -d $dir/bin ]]; then
export PATH="$PATH:$dir/bin"
FOUND_GOENV=1
fi
fi
fi
if [[ $FOUND_GOENV -eq 1 ]]; then
eval "$(goenv init -)"
function goenv_prompt_info() {
echo "$(goenv version-name)"
}
else
# fallback to system python
function goenv_prompt_info() {
echo "system: $(go verson 2>&1 | cut -f 3 -d ' ')"
}
fi
unset FOUND_GOENV goenvdirs dir