Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hitting tab in Zsh eats above lines

Tags:

zsh

oh-my-zsh

I just made the switch to Zsh, but I'm facing a weird problem with it: every time I hit the tab key, the prompt goes up a line, thus eating what was above.

In order to demonstrate the problem more clearly, I created a GIF:

enter image description here

I'm using a custom theme and Oh My Zsh. You can find the theme here: http://pastebin.com/12dZtZf3.

EDIT: The problem seems to reside in my theme, as using other themes solves the problem.

EDIT: The culprit seems to be in the function that prints the row of dashes and the date above the prompt:

_professional_prompt_header() {
  echo -n "$bg[grey]"

  for i in {0..$(( $(tput cols) / 2 - 6 ))}; do
    echo -n "--"
  done

  # Uncommenting this line fixes the problem.
  # Tried echo without -n and print, but no success.
  echo -n " %*$reset_color"      
}
like image 357
jviotti Avatar asked Oct 01 '22 20:10

jviotti


1 Answers

This has also emerged as an issue with multiline prompts in the release of zsh 5.3. As of 2017-01-13, a patch has not been released. A discussion and explanation can be found in this prezto issue.

More discussion of the offending zsh issue itself can be found here.

Hopefully a fix will emerge from the zsh project. If not, some workarounds mentioned on that github repo are to make your PROMPT variable only a single line, outputting any other lines in the precmd function. This seems like a pain, however, so until it is fixed (or decided to be a "feature"), the easiest fix sounds like it is to roll back to zsh 5.2.

like image 101
user1978019 Avatar answered Oct 04 '22 18:10

user1978019