X-Git-Url: https://git.r.bdr.sh/rbdr/dotfiles/blobdiff_plain/fa25023586cb94a1abf4fd3ff95ebe7c3c8ead09..8010d7b556a2c3c5945b2f1e94010d0dfd22b73c:/zsh/modules/prompt.zsh?ds=sidebyside diff --git a/zsh/modules/prompt.zsh b/zsh/modules/prompt.zsh index 945d9eb..0ab1e0d 100644 --- a/zsh/modules/prompt.zsh +++ b/zsh/modules/prompt.zsh @@ -16,31 +16,28 @@ function prompt_precmd { # Functions # -function virtualenv_info { - if [[ -z "$VIRTUAL_ENV" ]]; then - venv="default" - else - venv="${VIRTUAL_ENV##*/}" - fi - echo "🐍${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 "💎${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 "💛${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 { @@ -52,15 +49,24 @@ function box_name { # function zle-line-init zle-keymap-select { - local return_status="%{%F{red}%}%(?..🆇)%{$reset_color%}" + + # Couldn't figure out how to get tmux and iTerm to agree on how to render + # these characters... so there you go. + + local normal_symbol="N" + local insert_symbol="I" + local error_symbol="X" + + # Show vi status / return status on the right side + + local return_status="%{%F{red}%}%(?.. $error_symbol)%{$reset_color%}" if [ $KEYMAP = 'vicmd' ]; then - local edit_status="%{%F{cyan}%}🅽" + local edit_status="%{%F{cyan}%}$normal_symbol" else - local edit_status="%{%F{green}%}🅸" + local edit_status="%{%F{green}%}$insert_symbol" fi - RPS1="${edit_status} ${return_status}%{$reset_color%}" - RPS2=$RPS1 + RPROMPT="${edit_status}${return_status}%{$reset_color%}" zle reset-prompt } zle -N zle-line-init @@ -93,10 +99,12 @@ 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%} )$ ' } prompt_setup "$@" setopt PROMPT_SUBST +setopt PROMPT_PERCENT +setopt TRANSIENT_RPROMPT