#!/usr/bin/zsh prompt_end="∣%F{25}${PROMPT_FST}%B%F{26}${PROMPT_SND}%B%f " neg_user_pretok="${PROMPT_LHS}%f" [[ ${UID} -ne 0 ]] && _neg_promptcolor="${TILDA_COLOR}" && _neg_user_pretoken="${MAIN_COLOR}${PROMPT_LHS}%f" [[ ${UID} -ne 0 ]] && _neg_promptcolor="${TILDA_COLOR}" && _neg_user_token="${MAIN_COLOR}${PROMPT_RHS}${prompt_end}" setopt sh_word_split local _neg_dyn_pwd="" local _neg_full_path="$(pwd)" local _neg_tilda_path=${_neg_full_path/${HOME}/\~} # write the home directory as a tilda [[ ${_neg_tilda_path[2,-1]} == "/" ]] && _neg_tilda_path=${_neg_tilda_path[2,-1]} # otherwise the first element of split_path would be empty. local _neg_forwards_in_tilda_path=${_neg_tilda_path//[^["\/"]/} # remove everything that is not a "/" local _neg_number_of_elements_in_tilda_path=$(( $#_neg_forwards_in_tilda_path + 1 )) # we removed the first forward slash, so we need one more element than the number of slashes local _neg_saveIFS="${IFS}" IFS="/" local _neg_split_path=(${_neg_tilda_path}) local _neg_start_of_loop=1 local _neg_end_of_loop=${_neg_number_of_elements_in_tilda_path} for i in {$_neg_start_of_loop..$_neg_end_of_loop}; do if [[ $i == $_neg_end_of_loop ]]; then _neg_to_be_added=$_neg_split_path[i]'/' _neg_dyn_pwd=${_neg_dyn_pwd}${_neg_to_be_added} else _neg_to_be_added=${_neg_split_path[i]} _neg_to_be_added=${_neg_to_be_added}"%F{4}/%F{7}" # _neg_to_be_added=$_neg_to_be_added[1,1]'/' _neg_dyn_pwd=${_neg_dyn_pwd}${_neg_to_be_added} fi done unsetopt sh_word_split IFS=${_neg_saveIFS} [[ ${_neg_full_path/${HOME}/\~} != ${_neg_full_path} ]] && _neg_dyn_pwd=${_neg_dyn_pwd/\/~/~} # remove the slash in front of ${HOME} neg_prompt="%F${_neg_promptcolor}${_neg_dyn_pwd[0,-2]}%F{0}$_neg_user_token%b%k%f" builtin print "${neg_user_pretok}%f%40<..<${neg_prompt}"