* question about quoting % in preexec
@ 2004-08-27 15:20 Andy Spiegl
2004-08-27 15:54 ` Oliver Kiddle
0 siblings, 1 reply; 2+ messages in thread
From: Andy Spiegl @ 2004-08-27 15:20 UTC (permalink / raw)
To: ZSH User List
I am using the following preexec-function to display the currently running
process in my xterm-title:
preexec () {
print -Pn "\033]0;%n@%m <${(Vq)2}> %~\007"
print -Pn $icontitle
}
But if I run a command with "%" in the arguments, e.g.:
date "+%Y-%m-%d %H:%M:%S"
it leads to very unwanted results because zsh interprets it as variables.
How can I avoid this? I suppose I have to quote the %s but how?
Thanks so much for your help,
Andy.
--
o _ _ _
------- __o __o /\_ _ \\o (_)\__/o (_) -o)
----- _`\<,_ _`\<,_ _>(_) (_)/<_ \_| \ _|/' \/ /\\
---- (_)/ (_) (_)/ (_) (_) (_) (_) (_)' _\o_ _\_v
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Money often costs to much. -- Ralph Waldo Emerson
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: question about quoting % in preexec
2004-08-27 15:20 question about quoting % in preexec Andy Spiegl
@ 2004-08-27 15:54 ` Oliver Kiddle
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Kiddle @ 2004-08-27 15:54 UTC (permalink / raw)
To: Andy Spiegl; +Cc: ZSH User List
Andy Spiegl wrote:
> I am using the following preexec-function to display the currently running
> process in my xterm-title:
>
> preexec () {
> print -Pn "\033]0;%n@%m <${(Vq)2}> %~\007"
> print -Pn $icontitle
> }
>
> But if I run a command with "%" in the arguments, e.g.:
> date "+%Y-%m-%d %H:%M:%S"
>
> it leads to very unwanted results because zsh interprets it as variables.
> How can I avoid this? I suppose I have to quote the %s but how?
It would be easier to just split it across extra print commands:
print -Pn '\033]0;%n@%m <'
print -rn -- "${(Vq)2}"
print -Pn '> %~\007'
The -r option does raw output so no escapes are interpreted.
Oliver
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-08-27 15:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-27 15:20 question about quoting % in preexec Andy Spiegl
2004-08-27 15:54 ` Oliver Kiddle
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).