Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: What's wrong with PROMPT_SUBST? (Was: VCS info (Re: Call for good plugins list))
- X-seq: zsh-users 24687
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: What's wrong with PROMPT_SUBST? (Was: VCS info (Re: Call for good plugins list))
- Date: Wed, 12 Feb 2020 08:17:56 +0100
- In-reply-to: <CAH+w=7Z1yjRLWUCSr4VTSR0OEkmwEFwaz7Dy237ha4P1Ov05=w@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>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <etPan.59d1167f.1056949b.98a8@zdharma.org> <5dfbef9f-754f-8487-a6b8-44296cba1a11@eastlink.ca> <171001115438.ZM17268@torch.brasslantern.com> <1506886188.3585120.1124265296.1C8585C6@webmail.messagingengine.com> <171001145042.ZM17810@torch.brasslantern.com> <16D1FF19-CE8F-4A88-9AD0-1661BC3FD65F@larryv.me> <CAH+w=7Z1yjRLWUCSr4VTSR0OEkmwEFwaz7Dy237ha4P1Ov05=w@mail.gmail.com>
On 2/12/20, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Tue, Feb 11, 2020 at 1:38 AM Lawrence Velázquez <vq@xxxxxxxxx> wrote:
>>
>> > On Oct 1, 2017, at 5:50 PM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
>> > wrote:
>> >
>> > The main thing is that I despise prompt_subst
>>
>> Why is that?
>
> Mostly it's a matter of taste. It introduces yet another set of
> tokens that you have to escape to use literally in prompts, and I
> don't think the prompt is an appropriate place to be running command
> substitutions. It means even more possible collisions on variable
> names with unintended side-effects. Obviously these are things that
> can be avoided; I'd just rather not have to think about them.
One particular cargo culted piece of setup is the following combo,
setopt prompt_subst
preexec() {
print -P "$escape_to_set_terminal_title $1 $end_terminal_title"
}
which will result in the following command having funny results,
echo '$(killall -9 zsh)'
(the above code is wrong even without prompt_subst but the
consequences are quite a bit worse with it). The easy fix with
prompt_subst enabled is to use \$1 instead which should be more or
less fine as long as you haven't literally typed in the
$end_terminal_title code.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author