0

When I type for too long with zsh, the prompt disappears and it leaves a single character on the same line as the rest of what I was typing, the rest goes to a new line below it. Not sure how to tell if this is a COLUMNS issue or something completely different.

The .zshrc for the root user seems to work fine, with the Right Prompt going away once the input is long enough, and doesn't glitch out. My personal one also seems to fix itself once shifted to and from the master/stack in my window manager (AwesomeWM, not sure if that is affecting it)

Pictures:
ROOT PS1: https://imgur.com/a/pfWZB7x

PERSONAL PS1: https://imgur.com/lJMyw4k

Files:
ROOT .zshrc: https://paste.gnome.org/pff0tkabw

Personal .zshrc: https://paste.gnome.org/pxy8cfrcu

1 Answer 1

0

I'm guessing most of your .zshrc file has been lifted from an older, or somebody else's, .bashrc file, as there are a number of things in it that would be done differently in zsh compared to bash.

Your current prompt is set with

PS1='[${GREEN}%n${NC}@${GREEN}%m${NC}:${CYAN}%1~${NC}]%(?,,[${RED}%?${NC}])$(git_status)$ '

where $GREEN etc. are control sequences produced by tput.

This has the issue that the shell will have a hard time figuring out how wide the prompt is, since you're using your own escape sequences for coloring instead of using the standard way of doing it in zsh.

I would suggest you ditch your $GREEN etc. variable and instead use

PS1='[%F{green}%n%f@%F{green}%m%f:%F{cyan}%1~%f]%(?,,[%F{red}%?%f])$(git_status)$ '

Each %F{colorname} sets the foreground color to colorname and each %f stops using that color.

To properly use your own escape sequences, each such sequence should be enclosed in %{...%}, so that the shell knows that it will take no space in the prompt (the root user's initialization file does this, but in a roundabout way):

PS1='[%{${GREEN}%}%n%{${NC}%}@%{${GREEN}%}%m%{${NC}%}:%{${CYAN}%}%1~%{${NC}%}]%(?,,[%{${RED}%}%?%{${NC}%}])$(git_status)$ '

Note that this also means that the output from your git_status shell function, which contains color codes, needs to be updated.

Read the section entitled "EXPANSION OF PROMPT SEQUENCES" in the zshmisc manual.

1
  • Thank you, will do! Mar 13, 2021 at 16:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .