3

I'm new to zsh and also prezto. Now as in my bash shell I want to have the current path on the left and my current branch at the right as you can see in the picture so far so good.....

Prompt

... Now the problem is the right part of the prompt is in the second line and not in the one the path is in!

# Define prompts.
PROMPT="
[ ${_prompt_steeef_colors[3]}%n%f@${_prompt_steeef_colors[2]}%m%f ] ${_prompt_steeef_colors[5]}%~%f 
"'$python_info[virtualenv]'"$ "
RPROMPT='${vcs_info_msg_0_}'

(Complete source code: here)

How can I achieve both path and branch at the same line in my custom prezto prompt?

paulmelnikow
  • 16,895
  • 8
  • 63
  • 114
lony
  • 6,733
  • 11
  • 60
  • 92
  • 1
    I would suggest extending `PROMPT` to print the information at the right place and drop the use of `RPROMPT`. [This answer on U&L](http://unix.stackexchange.com/a/250457/52652) should help you with that. Also, I found that using literal newlines in `PROMPT` can lead to some issues: For me it sometimes led to the last line of the previous output overwritten by the prompt when a line in the prompt was exactly as long as the terminal wide (which may happen longer paths; and it was very irritating that `ls` seemed to show an empty directory, where I was expecting to see a single file). – Adaephon Apr 01 '16 at 07:27
  • To complex for me :( I tried. – lony Apr 02 '16 at 14:11

1 Answers1

4

If you don't care about rendering artifacts when resizing windows, you can use control characters to hack this functionality in:

local _lineup=$'\e[1A'
local _linedown=$'\e[1B'
RPROMPT=%{${_lineup}%}"some stuff"%{${_linedown}%}

I found this here: https://superuser.com/questions/357107/zsh-right-justify-in-ps1/737454#737454

Tim Helmstedt
  • 2,744
  • 1
  • 20
  • 10