jviotti
jviotti

Reputation: 18909

Issues with Zsh prompt

My Zsh prompt cursor is sometimes (most of the time actually) a line below were it should be (attaching screenshot):

enter image description here

If I hit enter multiple times, the prompt seems to get fixed:

enter image description here

My first thought is that it was an error within my custom prompt, so I replaced by prompt with a simple one containing only one digit:

PROMPT='> '

But the error persisted.

Any clues about what can be missing?

You can find my theme here: http://pastebin.com/cSJwGWKZ.

Notice that I'm using Oh My Zsh.

EDIT: The prompt seems to get fixed when I reach the bottom of the terminal (by hitting enters).

Upvotes: 1

Views: 2671

Answers (1)

Adaephon
Adaephon

Reputation: 18329

The culprit is %{$(echotc DO 1)%} in your RPROMPT, which moves the cursor one line down when printing RPROMPT. When reaching the bottom of your terminal there is no additional line to go down to, so the cursor just remains where it was.

Depending on where you want your RPROMPT you have basically two options:

  • On the same line as your input cursor (after λ):
    Just remove %{$(echotc DO 1)%} from your RPROMPT:

RPROMPT='$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%'
  • One line (or any other number of lines, really) above your input:
    Add %{$(echotc UP 1)%} at the beginning of your RPROMPT, this will move the cursor up one line, print the right prompt and move back down one line:

RPROMPT='%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'`

Note: the second method may lead to RPROMPT overwriting parts of PROMPT if both get to long and/or the terminal window to narrow. If RPROMPT remains on the same line as input, it will be hidden once the input reaches it (and will reapper if you delete some of the input).

Upvotes: 6

Related Questions