oops accidentally fucked up the prompt

This commit is contained in:
Erin 2022-10-15 21:39:29 -04:00
parent b25aa8dffb
commit c07e94c639

View file

@ -7,24 +7,23 @@ function precmd {
vcs_info vcs_info
# Start with a fresh prompt # Start with a fresh prompt
RPROMPT="" RPROMPT=""
some_line=""
if [ -z $new_session ]; then if [ -z $new_session ]; then
# If this is the first prompt in a session, there's not much to say # If this is the first prompt in a session, there's not much to say
RPROMPT="%B%F{cyan}new session%f%b" RPROMPT="%B%F{cyan}new session%f%b"
new_session=1 new_session=1
else else
# Show exit code + more info about the last command run as a separate line # Show exit code + more info about the last command run as a separate line
some_line="exited %B%(?.%F{green}%?%f.%F{red}%?%f)%b" RPROMPT="exited %B%(?.%F{green}%?%f.%F{red}%?%f)%b"
if [ -z $timer ]; then if [ -z $timer ]; then
# If we never set $timer, preexec was never run (e.g. ^C at prompt) # If we never set $timer, preexec was never run (e.g. ^C at prompt)
some_line="$(print -P "%B%F{cyan}no exec%f%b, $some_line")" RPROMPT=="$(print -P "%B%F{cyan}no exec%f%b, $RPROMPT")"
else else
# Calculate elapsed real time for last command # Calculate elapsed real time for last command
now="$(date +%s.%N)" now="$(date +%s.%N)"
if [[ $(($now - $timer)) > 0.5 ]]; then if [[ $(($now - $timer)) > 0.5 ]]; then
timer_show=$(($now - $timer)) timer_show=$(($now - $timer))
timer_show=$(printf '%.*f\n' 3 $timer_show) timer_show=$(printf '%.*f\n' 3 $timer_show)
some_line="took %B%F{cyan}${timer_show}s%f%b, $some_line" RPROMPT="took %B%F{cyan}${timer_show}s%f%b, $RPROMPT"
fi fi
fi fi
fi fi