1 autoload
-Uz promptinit
&& promptinit
3 function tool_versions
() {
4 if [[ -s ".tool-versions" ]]; then
8 echo "${HOME}/.tool-versions"
11 if [[ "$TERM" == (dumb
|linux
|*bsd
*) ]] || (( $#prompt_argv < 1 )); then
19 function env_info_provider
() { echo "%{%F{green}%}n/a"; }
21 echo "[%{%F{cyan}%}ENV%{%F{black}%} $(env_info_provider)%{%F{black}%}]"
24 function python_info
{
25 pythoninfo
=`cat "$(tool_versions)" | rg python | cut -d ' ' -f 2`
26 pythoninfo
=${ASDF_PYTHON_VERSION:-$pythoninfo}
27 venv
="${VIRTUAL_ENV##*/}"
28 echo "%{%F{green}%}py%{%F{black}%} ${pythoninfo:-no}@${venv:-default}"
32 rustinfo
=`cat "$(tool_versions)" | rg rust | cut -d ' ' -f 2`
33 rustinfo
=${ASDF_RUST_VERSION:-$rustinfo}
34 echo "%{%F{red}%}rs%{%F{black}%} ${rustinfo:-no}"
38 nodeinfo
=`cat "$(tool_versions)" | rg nodejs | cut -d ' ' -f 2`
39 nodeinfo
=${ASDF_NODEJS_VERSION:-$nodeinfo}
40 echo "%{%F{yellow}%}js%{%F{black}%} ${nodeinfo:-no}"
44 branch
=$(git branch --show-current 2> /dev/null)
46 if [ ! -z $branch ]; then
47 echo -n "@%F{cyan}$branch%f"
49 status_output
=$(git status --short)
51 if echo "$status_output" | grep -q '^??'; then
52 echo -n "%{%F{magenta}%}?%f"
55 if echo "$status_output" | grep -q '^ M'; then
56 echo -n "%{%F{magenta}%}!%f"
59 if echo "$status_output" | grep -q '^ D'; then
60 echo -n "%{%F{magenta}%}×%f"
63 if echo "$status_output" | grep -q '^A '; then
64 echo -n "%{%F{green}%}+%f"
70 [ -f ~
/.box
-name ] && cat ~
/.box
-name || hostname
-s
77 function zle
-line-init zle
-keymap-select {
79 # Couldn't figure out how to get tmux and iTerm to agree on how to render
80 # these characters... so there you go.
82 local normal_symbol
="N"
83 local insert_symbol
="I"
84 local error_symbol
="X"
86 # Show vi status / return status on the right side
88 local return_status
="%{%F{red}%}%(?.. $error_symbol)%{$reset_color%}"
89 if [ $KEYMAP = 'vicmd' ]; then
90 local edit_status
="%{%F{cyan}%}$normal_symbol"
92 local edit_status
="%{%F{green}%}$insert_symbol"
95 RPROMPT
="${edit_status}${return_status}%{$reset_color%}"
99 zle
-N zle
-keymap-select
105 function prompt_setup
{
107 unsetopt XTRACE KSH_ARRAYS
108 prompt_opts
=(cr percent subst
)
110 # Load required functions.
111 autoload
-Uz add
-zsh-hook
115 %{%F{black}%}$(env_info) $(node_info) $(rust_info) $(python_info)
116 %{%F{magenta}%}%n%{%f%}@%{%F{yellow}%}$(box_name)%{%f%} %{%B%F{green}%}${PWD/#$HOME/~}%{%f%b%}$(git_info)%{%f%}
117 %(?,,%{${%B%F{white}%}[%?]%{%f%b%} )%% '
122 setopt PROMPT_PERCENT
123 setopt TRANSIENT_RPROMPT