I recently wrote a function called zuperPrompt
that prints out a nice looking prompt and I've set my PROMPT variable in my .zshrc to call that function like so:
setopt PROMPT_SUBST
PROMPT='$(zuperPrompt)'
It is the same issue found here, but I think the problem there was from using a newline escape character in the awk command. I tried doing the whole prompt without any newline characters, but I got the same result :(
Here is the function:
zuperPrompt() {
# count chars in directory name
num_chars=1
if [ ! $(dirs) = '~' ]; then
let "num_chars=$(basename "`pwd`" | wc -m) - 1"
fi
# draw line
line="\n╭──"
for i in {1..$num_chars}; do
line+="─"
done
line+="──╯"
directory="%F{8}%K{8}%B%F{blue}%1~%k%F{8}"
arrows="%B%F{magenta}❯%B%F{yellow}❯%F{cyan}❯ "
row1="\n%B%F{green}◆ "$directory"─╮"
row2=$line
row3="\n╰─ "$arrows
print -P $row1$row2$row3
}
Here is the result of pressing tab after typing python3
I'm not sure what is going on here. Thank you in advance if anyone can help!
Update after looking at the syntax highlighting of this in my web browser, I see that $row3 is a different color than the others. I ran my code with just $row1$row2 and it works fine with no shifting of the cursor. Anyone know what's going on there?
Update 2 I removed the -P option from the final print statement and it is working with all three rows.