Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Dynamic parameters for PROMPT_SUBST functions
- X-seq: zsh-users 24934
- From: Sebastian Stark <sstark+zsh@xxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Dynamic parameters for PROMPT_SUBST functions
- Date: Fri, 19 Jun 2020 08:32:33 +0200
- 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>
- Mail-followup-to: zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Sender: zsh-users@xxxxxxx
Hello,
I am trying to have a function call in my prompt that gets the return
value of the last command as a parameter (%?).
However I am having trouble to get this right. Instead of an actual
number, what is handed to the function is the literal string %?.
Is there anything I can do better or is this just not possible?
I could probably use $? in the function itself, but that sounds a bit
fragile to me because I maybe get a different value of $?.
In this example I write the parameter to a file, because if I just print
it it would get printed as a literal %? and expanded later and thus hide
the issue I am facing
% zsh -f
% x(){print $1 >>/tmp/lll}
% setopt PROMPT_SUBST
% PROMPT=$'$(x %?) %m%# '
% cat /tmp/lll
%?
Thanks for any hints.
Sebastian
Messages sorted by:
Reverse Date,
Date,
Thread,
Author