X-Git-Url: https://git.r.bdr.sh/rbdr/dotfiles/blobdiff_plain/6f7715ef506f39a0b0d9a5cd2afc7ed7a7202064..refs/heads/main:/zsh/modules/prompt.zsh diff --git a/zsh/modules/prompt.zsh b/zsh/modules/prompt.zsh index 18e5cc4..615ca95 100644 --- a/zsh/modules/prompt.zsh +++ b/zsh/modules/prompt.zsh @@ -1,75 +1,9 @@ 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 -# -# Functions -# - -function env_info_provider() { echo "%{%F{green}%}n/a"; } -function env_info { - echo "[%{%F{cyan}%}ENV%{%F{black}%} $(env_info_provider)%{%F{black}%}]" -} - -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 rust_info { - rustinfo=`cat "$(tool_versions)" | rg rust | cut -d ' ' -f 2` - rustinfo=${ASDF_RUST_VERSION:-$rustinfo} - echo "%{%F{red}%}rs%{%F{black}%} ${rustinfo:-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 git_info { - branch=$(git branch --show-current 2> /dev/null) - - if [ ! -z $branch ]; then - echo -n "@%F{cyan}$branch%f" - - status_output=$(git status --short) - - if echo "$status_output" | grep -q '^??'; then - echo -n "%{%F{magenta}%}?%f" - fi - - if echo "$status_output" | grep -q '^ M'; then - echo -n "%{%F{magenta}%}!%f" - fi - - if echo "$status_output" | grep -q '^ D'; then - echo -n "%{%F{magenta}%}×%f" - fi - - if echo "$status_output" | grep -q '^A '; then - echo -n "%{%F{green}%}+%f" - fi - fi -} - -function box_name { - [ -f ~/.box-name ] && cat ~/.box-name || hostname -s -} - # # ZLE widgets # @@ -113,7 +47,7 @@ function prompt_setup { # Define prompts. PROMPT=' %{%F{black}%}$(env_info) $(node_info) $(rust_info) $(python_info) -%{%F{magenta}%}%n%{%f%}@%{%F{yellow}%}$(box_name)%{%f%} %{%B%F{green}%}${PWD/#$HOME/~}%{%f%b%}$(git_info)%{%f%} +%{%F{magenta}%}%n%{%f%}@%{%F{yellow}%}$(hostname -s)%{%f%} %{%B%F{green}%}${PWD/#$HOME/~}%{%f%b%}$(git_info)%{%f%} %(?,,%{${%B%F{white}%}[%?]%{%f%b%} )%% ' }