From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19764 invoked by alias); 7 Dec 2011 10:10:53 -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: 16610 Received: (qmail 16884 invoked from network); 7 Dec 2011 10:10:40 -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.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 74.125.82.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Ir4zN8gi+INZ3bnzq7nKcSTizqIbOLtf+A39pB6Rlco=; b=jJadam80NoMWPdIzk7RhN/7vl2smQYTap/zQkHM1ewn8OAA1O4PkUp1SEyx3rBvBlr OZ5IwEYf0megRKBZHQsSgaxfXCpcX5F/Nzkfg2E2pCdLysVxDH9+dYD6lk0+Y4CfZ0GE CqA6xtWxyvOaF44QLd8E204/Xrjnz3nvyEMH0= MIME-Version: 1.0 In-Reply-To: <111207001606.ZM28228@torch.brasslantern.com> References: <20111207044346.GA6356@primenet.com.au> <111207001606.ZM28228@torch.brasslantern.com> Date: Wed, 7 Dec 2011 18:10:32 +0800 Message-ID: Subject: Re: Could you provide bash's \$ which like zsh %#? From: Daniel Lin To: Bart Schaefer Cc: Zsh Users Content-Type: multipart/alternative; boundary=0015174a0bb420ada604b37dc3c8 --0015174a0bb420ada604b37dc3c8 Content-Type: text/plain; charset=UTF-8 Thanks, learn a lot. 2011/12/7 Bart Schaefer > 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.] > --0015174a0bb420ada604b37dc3c8--