zsh-users
 help / color / mirror / code / Atom feed
* Dynamic parameters for PROMPT_SUBST functions
@ 2020-06-19  6:32 Sebastian Stark
  2020-06-19  6:58 ` Lawrence Velázquez
  2020-06-19 10:56 ` Daniel Shahaf
  0 siblings, 2 replies; 6+ messages in thread
From: Sebastian Stark @ 2020-06-19  6:32 UTC (permalink / raw)
  To: zsh-users


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-21 15:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-19  6:32 Dynamic parameters for PROMPT_SUBST functions Sebastian Stark
2020-06-19  6:58 ` Lawrence Velázquez
2020-06-19 10:56 ` Daniel Shahaf
2020-06-19 17:08   ` Sebastian Stark
2020-06-20 11:06     ` Daniel Shahaf
2020-06-21 15:17       ` Sebastian Stark

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).