Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a weird behaviour that seems to be a combination of zsh and maybe urxvt (?) My setup is this: I start urxvt -e 'tmux' to get myself a terminal which launches zsh as the default shell.

I then started customizing my $PROMPT and it currently looks like this:

 zstyle ':vcs_info:*' enable git svn hg bzr
 zstyle ':vcs_info:*' formats $' \e[0;33m(%s:%b)\e[0m'
 precmd () { vcs_info }
 PROMPT+=$'\e[0;31m%n\e[0m'
 PROMPT+="@"
 PROMPT+=$'\e[0;34m%m\e[0m'
 PROMPT+=":"
 PROMPT+=$'\e[0;36m%3c\e[0m'
 PROMPT+=$'\e[0;33m%c\e[0m'
 PROMPT+='${vcs_info_msg_0_}'
 export PROMPT

You might notice the second %c line, that is, of course, for testing.

The normal behaviour of a prompt is to create a new line after pressing enter, optionally executing the command that may be present. The a new line is printed. However, I notice a different behaviour under certain circumstances: When I press enter, the command is executed and the output is displayed. However, when the previous prompt was not at the top of the terminal, the last line of previous output is overwritten because the whole new output is moved one line upwards.

Maybe an example is in order. Start with an empty terminal and a new prompt:

user@hostname:very long directory name/with multiple components/foo~very long directory name/with multiple components/foo (git:master)

Now we enter ls -la in this directory (sample output):

user@hostname:very long directory name/with multiple components/foo~very long directory name/with multiple components/foo (git:master)ls -la
drwxr-xr-x 7 user user 4096 25. Jan 16:17 .
drwxr-xr-x 7 user user 4096 25. Jan 16:17 ..
user@hostname:very long directory name/with multiple components/foo~very long directory name/with multiple components/foo (git:master)

Notice how there is something missing, as in reality, there is a .git directory in here:

drwxr-xr-x 7 user user 4096 25. Jan 16:17 .
drwxr-xr-x 7 user user 4096 25. Jan 16:17 ..
drwxr-xr-x 7 user user 4096 25. Jan 16:17 .git

What happened here is easily described: The command output is generated correctly but then the prompt line is moved up by one line and overwrites the last line of output. So if I do the same again, my output looks like this:

user@hostname:very long directory name/with multiple components/foo~very long directory name/with multiple components/foo (git:master)ls -la
drwxr-xr-x 7 user user 4096 25. Jan 16:17 .
user@hostname:very long directory name/with multiple components/foo~very long directory name/with multiple components/foo (git:master)ls -la
drwxr-xr-x 7 user user 4096 25. Jan 16:17 .
drwxr-xr-x 7 user user 4096 25. Jan 16:17 ..
user@hostname:very long directory name/with multiple components/foo~very long directory name/with multiple components/foo (git:master)

As you can see, everything was moved up once again, this time replacing the .. from the last output and the .git from this output.

But this does not happen on all setups. It only happens, when the window is too narrow. I additionally, tested this by resizing the open urxvt window with zsh inside. When I make it too narrow. From what I see it starts once the prompt takes up about two thirds of the windows width. However, I don't know why this happens on this occassion.

Some notes: - It does not happen with bash (even when the prompt itself is multiline) - RPROMPT and RPROMPT2 are empty - It does not seem to depend on the type of information displayed (i.e. disabling vcs_info only helps if the prompt gets short enough again) - It does not happen when the prompt is multiline (and the second line does not reach the two-thirds mark) - It does not happen in a console (tty), but it does happen with xterm and urxvt.

Summary: My zsh prompt moves when line upwards if the prompt line is about two thirds of the window long.

share|improve this question

1 Answer 1

I seem to have fixed it by using %{fg[color]%} instead of the bash color codes (of course for that I need to load the color module).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.