zsh-users
 help / color / mirror / code / Atom feed
From: Shiyao Ma <i@introo.me>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-users@zsh.org
Subject: Re: How to stop dir expansion in the prompt?
Date: Wed, 5 Nov 2014 09:27:04 +0800	[thread overview]
Message-ID: <CAJQX3DxCnWfrKJsG0n1abTzJ9dWKgT1dOjFZUL9GX-3+m8+=EA@mail.gmail.com> (raw)
In-Reply-To: <141104084328.ZM1145@torch.brasslantern.com>

Thanks.

Problem solved.

2014-11-05 0:43 GMT+08:00 Bart Schaefer <schaefer@brasslantern.com>:
> On Nov 4,  5:42pm, Shiyao Ma wrote:
> }
> } When outside a vcs directory, `echo $vcs_info_msg_0_` gives %d, which
> } is the same string in zstyle nvcsformat.
>
> Ah, of course.  You want:
>
> PROMPT="%(?.${success_color}.${failure_color})${SSH_TTY:+[%n@%m]}%B%${max_path_chars}<...<"'${${(%)vcs_info_msg_0_}/#$HOME/~}'"%<<%(!.${root_char}.${user_char})%b%f
> "
>
> The (%) in ${(%)vcs_info_msg_0_} tells it to do prompt expansion right
> away, rather than return the format for the prompt to expand later, so
> then the /#$HOME/ can do its work.
>
> } Yup. One minor question. No matter how many % I write, like this
> } one:echo  ${vcs_info_msg_0_%%%%%}, it's the same as echo
> } ${vcs_info_msg_0_}. So what's % here?
>
> ${NAME%PATTERN}
> ${NAME%%PATTERN}
>      If the PATTERN matches the end of the value of NAME, then
>      substitute the value of NAME with the matched portion deleted;
>      otherwise, just substitute the value of NAME.  In the first form,
>      the smallest matching pattern is preferred; in the second form,
>      the largest matching pattern is preferred.
>
> So after the first two %%, any more % you add become the pattern, which
> is unlikely to match in a directory name.
>
> I don't know why Julien left %% in there with no pattern after it.



-- 

吾輩は猫である。ホームーページはhttp://introo.me。


      reply	other threads:[~2014-11-05  1:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-04  3:23 Shiyao Ma
2014-11-04  3:43 ` Bart Schaefer
2014-11-04  6:30   ` Shiyao Ma
2014-11-04  7:36     ` Bart Schaefer
2014-11-04  9:42       ` Shiyao Ma
2014-11-04 16:43         ` Bart Schaefer
2014-11-05  1:27           ` Shiyao Ma [this message]

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='CAJQX3DxCnWfrKJsG0n1abTzJ9dWKgT1dOjFZUL9GX-3+m8+=EA@mail.gmail.com' \
    --to=i@introo.me \
    --cc=schaefer@brasslantern.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).