aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2022-07-06 12:28:02 +0200
committerRuben Beltran del Rio <ruben@unlimited.pizza>2022-07-06 12:28:02 +0200
commit7cb68b21872488f820f4a05f61c0617d2895a729 (patch)
tree1043526bbe8af1a7637e0083c02bb700570911ae
parent4cf8c0a239326c9cb91a7b3bf1f75591bf0b4703 (diff)
Allow for local tool versions
-rw-r--r--zsh/modules/prompt.zsh14
1 files changed, 11 insertions, 3 deletions
diff --git a/zsh/modules/prompt.zsh b/zsh/modules/prompt.zsh
index 0ab1e0d..beeb85d 100644
--- a/zsh/modules/prompt.zsh
+++ b/zsh/modules/prompt.zsh
@@ -1,5 +1,13 @@
autoload -Uz promptinit && promptinit
+function tool_versions() {
+ if [[ -s ".tool-versions" ]]; then
+ echo '.tool-versions'
+ return
+ fi
+ echo "${HOME}/.tool-versions"
+}
+
if [[ "$TERM" == (dumb|linux|*bsd*) ]] || (( $#prompt_argv < 1 )); then
prompt 'off'
fi
@@ -22,20 +30,20 @@ function env_info {
}
function python_info {
- pythoninfo=`cat ~/.tool-versions | rg python | cut -d ' ' -f 2`
+ pythoninfo=`cat "$(tool_versions)" | rg python | cut -d ' ' -f 2`
pythoninfo=${ASDF_PYTHON_VERSION:-$pythoninfo}
venv="${VIRTUAL_ENV##*/}"
echo "%{%F{green}%}py%{%F{black}%} ${pythoninfo:-no}@${venv:-default}"
}
function ruby_info {
- rubyinfo=`cat ~/.tool-versions | rg ruby | cut -d ' ' -f 2`
+ rubyinfo=`cat "$(tool_versions)" | rg ruby | cut -d ' ' -f 2`
rubyinfo=${ASDF_RUBY_VERSION:-$rubyinfo}
echo "%{%F{red}%}rb%{%F{black}%} ${rubyinfo:-no}"
}
function node_info {
- nodeinfo=`cat ~/.tool-versions | rg nodejs | cut -d ' ' -f 2`
+ nodeinfo=`cat "$(tool_versions)" | rg nodejs | cut -d ' ' -f 2`
nodeinfo=${ASDF_NODEJS_VERSION:-$nodeinfo}
echo "%{%F{yellow}%}js%{%F{black}%} ${nodeinfo:-no}"
}