From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4544 invoked by alias); 7 Dec 2011 08:16:32 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16609 Received: (qmail 11957 invoked from network); 7 Dec 2011 08:16:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <111207001606.ZM28228@torch.brasslantern.com> Date: Wed, 07 Dec 2011 00:16:06 -0800 In-reply-to: Comments: In reply to Daniel Lin "Re: Could you provide bash's \$ which like zsh %#?" (Dec 7, 3:04pm) References: <20111207044346.GA6356@primenet.com.au> In-reply-to: Comments: In reply to Daniel Lin "Re: Could you provide bash's \$ which like zsh %#?" (Dec 7, 1:03pm) X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Daniel Lin Subject: Re: Could you provide bash's \$ which like zsh %#? Cc: Zsh Users MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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.]