Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to stop dir expansion in the prompt?
- X-seq: zsh-users 19344
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx, zsh-users@xxxxxxx
- Subject: Re: How to stop dir expansion in the prompt?
- Date: Tue, 04 Nov 2014 08:43:28 -0800
- In-reply-to: <CAJQX3DyTRTz9z6UoGNnOb2m9Bc_E9UTBSiLNxonz7SEb=bh4tQ@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAJQX3DyxOGy=_B4hSRcVSkea=k0V=8Am+ri4_khJ5Hwy5bMnnQ@mail.gmail.com> <141103194346.ZM32278@torch.brasslantern.com> <CAJQX3DzO+M4E7saUp1dBWGmrUYws3vYRASj=Bq2Euj7vRd6Qkg@mail.gmail.com> <141103233651.ZM32506@torch.brasslantern.com> <CAJQX3DyTRTz9z6UoGNnOb2m9Bc_E9UTBSiLNxonz7SEb=bh4tQ@mail.gmail.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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author