zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Daniel Lin <dlin.tw@gmail.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Could you provide bash's \$ which like zsh %#?
Date: Wed, 07 Dec 2011 00:16:06 -0800	[thread overview]
Message-ID: <111207001606.ZM28228@torch.brasslantern.com> (raw)
In-Reply-To: <CAPg-njwHDMbr1JT4xUH9degbZJu-41ED-q5DnoJKz5cJv_MY-w@mail.gmail.com>
In-Reply-To: <CAPg-njyfncx5imW8P1ozAuOGKLZQd3fk3wF8wtUxnegAWpgdYA@mail.gmail.com>

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.]


  reply	other threads:[~2011-12-07  8:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-07  4:43 Fwd: " Geoff Wing
2011-12-07  4:56 ` Jos Backus
2011-12-07  5:03   ` Daniel Lin
2011-12-07  5:09     ` Jos Backus
     [not found]       ` <CAPg-njwWN=a6XDv047MwXVSYzuX3Ew5u5tprTnRqFeTpnUopcQ@mail.gmail.com>
     [not found]         ` <CAETOPp3+tdbAMmf9T49Hqc1gfZvYqzXgiLRiAZ=aSCkwWsHKKw@mail.gmail.com>
2011-12-07  7:04           ` Daniel Lin
2011-12-07  8:16             ` Bart Schaefer [this message]
2011-12-07 10:10               ` Daniel Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=111207001606.ZM28228@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=dlin.tw@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).