Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: get output of a command in prompt
- X-seq: zsh-users 10731
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: get output of a command in prompt
- Date: Sun, 17 Sep 2006 09:58:28 -0700
- In-reply-to: <20060917141420.GA5288@xxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20060916184913.GA18417@xxxxxxxxxxxxxxxxxxxxx> <20060916190154.GA24023@xxxxxxxxxxxxxxx> <20060917141420.GA5288@xxxxxxxxxxxxxxxxxxxxx>
On Sep 17, 4:14pm, arno. wrote:
}
} Le Saturday 16 September 2006, à 21:01:55PM +0200, Frank a écrit :
} > zsh% PS1='$(printf "%s: %d" "This is a one" 1)-%% '
} > $(printf ": /home/hawk" "This is a one" 1)-% setopt promptsubst
} > This is a one: 1-%
}
} Yes, I've tried things like that, but the problem is that command output
} will be evaluated once, just when prompt is set up.
Not true. The quoting is important: Note where single quotes (') have
been used and where double quotes have. Compare:
PS1="$(printf '%s: %d' 'This is a one' 1)-%% " ;: This is the wrong way
PS1='$(printf "%s: %d" "This is a one" 1)-%% ' ;: This is the right way
} It will not be evaluated each time prompt is displayed
It will if the quoting is right and the promptsubst option has been set.
Question for zsh-workers: Why is the prompt string being evaluated more
than once on every zle reset?
torch% PS1='z is $((++z)) %# '
z is $((++z)) % setopt promptsubst
z is 2 % echo I expect three
I expect three
z is 5 %
z is 8 % echo I guess I should expect eleven
I guess I should expect eleven
z is 11 %
This could be expensive for command substitutions in the prompt.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author