Re: Mimic zsh's right prompt in bash
* Stephane CHAZELAS (Thu, 31 May 2007 19:06:50 GMT)
> 2007-05-31, 19:17(+01), Thorsten Kampe:
> > * Thorsten Kampe (Thu, 31 May 2007 19:02:46 +0100)
> >> * Thorsten Kampe (Thu, 31 May 2007 18:25:17 +0100)
> >> > How can I mimic a typical zsh prompt with the current directory at the
> >> > right in bash?
> >> >
> >> > My zsh prompt is:
> >> > user@host% /path/to/pwd
> >> >
> >> > How can I mimic the right hand side in bash with PS1?
> >>
> >> Oops, that's already been asked in May. I'll read through the
> >> thread...
> >
> > Hm, interesting thread but no answer given. I /guess/ it should be
> > possible to mimic the RPS1 in bash by extending the PS1 prompt to the
> > right.
>
> You want to try things like:
>
> PROMPT_COMMAND='printf "%*s\r" "$COLUMNS" "$PWD"'
That's pretty clever but unfortunately the PROMPT_COMMAND uses an
additional line - it doesn't display on the same line as PS1. This is
the same effect as having a two line prompt.
To explain: I started with a two line prompt like many people:
/path/to/pwd
user@host$
....but then I noticed that half of my screen is always only used for
the pwd prompt. Then I switched to
user@host[$basename]$
That's better but now I have only the last component of the path in
the prompt and the prompt length still changes with the directory
(okay, of course not as much as if I would put the whole path in the
brackets).
Zsh's solution to this command dilemma is brilliant: put the path to
the space that is hardly ever used: the space on the right.
Thorsten
|