I'd like a multi-line zsh prompt with a right alined part, that will look something like this:

2.nate@host:/current/dir                                               16:00
->

I know about RPROMPT in zsh, but that has a right-aligned prompt opposite your normal prompt, which is on the same line of text as your typing.

Is there a way to have a right-aligned portion to the first line of a multi-line command prompt? I'm looking for either a directive in the PS1 variable that says 'right align now' or a variable that is to PS1 what RPROMPT is to PROMPT.

Thanks!

link|improve this question

feedback

1 Answer

up vote 2 down vote accepted

You will find a detailed answer and an example here. The idea is to write the line before PS1 using the precmd callback, use $COLUMNS, and a bit of math to calculate the position of the text on the right side of the screen. Also a little bit of knowdledge of escape sequences will help you with cursor positioning and coloring.

Another solution can be to use a theme from Oh My ZSH/oh-my-zsh).

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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