Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Could you provide bash's \$ which like zsh %#?



Thanks, learn a lot.

2011/12/7 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>

> On Dec 7,  1:03pm, Daniel Lin wrote:
> } Subject: Re: Could you provide bash's \$ which like zsh %#?
> }
> } Sorry, I've tried, it display strange things.
> } PS1='%# %(#,$,%%)'
>
> That was Josh's attempt to give you one example that shows both %#
> and a conditional string that displays something not quite the same,
> so that you could compare the two.  It was not intended to be the
> prompt that you would use, just a sample of what could be done.
>
> On Dec 7,  3:04pm, Daniel Lin wrote:
> } Subject: Re: Could you provide bash's \$ which like zsh %#?
> }
> } So, to match the document, I should change the prompt to
> } PS1='%(!.#.$)'
>
> Yes, almost.  You probably want the trailing space in there.
>
> PS1='%(!.#.$) '
>
> Equivalently, %(#,#,$) says "if the UID is zero, pound, else dollar"
> "Running with privileges" could mean something other than "running as
> the root user" in obscure circumstances.  %(#,,) is the generalized
> form of %(!,,), so that you can test for explicit UID; the default
> when no UID is given is zero.  So another possible example is
>
> PS1='%(2#,Running as daemon ,)%(!.#.$) '
>
> [Assuming that UID 2 is "daemon" as it is on my Linux box.]
>


Messages sorted by: Reverse Date, Date, Thread, Author