]> git.r.bdr.sh - rbdr/dotfiles/blobdiff - zsh/modules/prompt.zsh
Simplify prompt functions
[rbdr/dotfiles] / zsh / modules / prompt.zsh
index 482bfc780ceba396f66281251455f24b9ff07f5f..a3051788869a112d3bdc88941f0dceb91aface45 100644 (file)
@@ -16,31 +16,25 @@ function prompt_precmd {
 # Functions
 #
 
-function virtualenv_info {
-  if [[ -z "$VIRTUAL_ENV" ]]; then
-    venv="default"
-  else
-    venv="${VIRTUAL_ENV##*/}"
-  fi
-  echo "%{%F{green}%}py%{%F{black}%} ${venv}"
+function env_info_provider() { echo "%{%F{green}%}n/a"; }
+function env_info {
+  echo "[%{%F{cyan}%}ENV%{%F{black}%} $(env_info_provider)%{%F{black}%}]"
 }
 
-function rvm_info {
-  if [[ -z "$RUBY_VERSION" ]]; then
-    rvminfo="default"
-  else
-    rvminfo=`rvm-prompt`
-  fi
-  echo "%{%F{red}%}rb%{%F{black}%} ${rvminfo}"
+function python_info {
+  pythoninfo=`cat ~/.tool-versions | rg python | cut -d ' ' -f 2`
+  venv="${VIRTUAL_ENV##*/}"
+  echo "%{%F{green}%}py%{%F{black}%} ${pythoninfo:-no}@${venv:-default}"
 }
 
-function nvm_info {
-  if [[ -z "$NVM_BIN" ]]; then
-    nvminfo="default"
-  else
-    nvminfo=`nvm current`
-  fi
-  echo "%{%F{yellow}%}js%{%F{black}%} ${nvminfo}"
+function ruby_info {
+  rubyinfo=`cat ~/.tool-versions | rg ruby | cut -d ' ' -f 2`
+  echo "%{%F{red}%}rb%{%F{black}%} ${rubyinfo:-no}"
+}
+
+function node_info {
+  nodeinfo=`cat ~/.tool-versions | rg nodejs | cut -d ' ' -f 2`
+  echo "%{%F{yellow}%}js%{%F{black}%} ${nodeinfo:-no}"
 }
 
 function box_name {
@@ -102,7 +96,7 @@ function prompt_setup {
 
   # Define prompts.
   PROMPT='
-%{%F{black}%}$(nvm_info) $(rvm_info) $(virtualenv_info)
+%{%F{black}%}$(env_info) $(node_info) $(ruby_info) $(python_info)
 %{%F{magenta}%}%n%{%f%}@%{%F{yellow}%}$(box_name)%{%f%} %{%B%F{green}%}${PWD/#$HOME/~}%{%f%b%}${git_info[prompt]} %{%f%}
 %(?,,%{${%B%F{white}%}[%?]%{%f%b%} )$ '
 }