X-Git-Url: https://git.r.bdr.sh/rbdr/dotfiles/blobdiff_plain/64c29a52f870d51090107d44e3fe85cdce7d63ff..560f8add36301dca59081b8e57ef66590736fe74:/zsh/modules/prompt.zsh?ds=inline diff --git a/zsh/modules/prompt.zsh b/zsh/modules/prompt.zsh index 482bfc7..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 @@ -16,31 +24,28 @@ 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` + pythoninfo=${ASDF_PYTHON_VERSION:-$pythoninfo} + 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` + 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=${ASDF_NODEJS_VERSION:-$nodeinfo} + echo "%{%F{yellow}%}js%{%F{black}%} ${nodeinfo:-no}" } function box_name { @@ -102,7 +107,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%} )$ ' }