Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: /usr/bin/printf
- X-seq: zsh-users 13840
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: /usr/bin/printf
- Date: Fri, 13 Feb 2009 11:40:46 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=PWv4jxeXjJjtQDSDQWLdSLpoCcPtpUOOHgggUcu1xzw=; b=QpB0DdzYHZbMN5P0/tZopvjoEgex2IvGZFc620XlvK4Rax4x56fFmYclUQ+N6R5zTF h+aL0/n4of4vsyE3XLZldb6EMBdtmHyp357Fq2jZgKrCKQNa6DpDynguWOsvadOLpg1B p6oaOcYwwYTAK9d27wlHp2YqK7K6VsEU/2fFE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=FkqQZls+kbT40s9LTEPqdNnLG6oE5p0emuxwZJoJBjIwzcINZBTslPr49yZsFOs1DS +2oL1q9L8l5TOO3yPKLCsU269UpBsepCz+Y5TR15IJs0d/HzkJVoF9Jwb9p4a/PXxydi h9xk6R74jchp+kip+Cbcr1YiOgglooIIKFQNM=
- In-reply-to: <4994F382.5090205@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <4994CFCF.2090408@xxxxxxxxxx> <237967ef0902121751k37dd810co312238682d9b60f0@xxxxxxxxxxxxxx> <4994E32E.2050508@xxxxxxxxxx> <090212192523.ZM11726@xxxxxxxxxxxxxxxxxxxxxx> <dbfc82860902121940x7270f12dt13f10d706c9e65fb@xxxxxxxxxxxxxx> <4994F382.5090205@xxxxxxxxxx>
2009/2/13 Matthew Flaschen <matthew.flaschen@xxxxxxxxxx>:
> Nikolai Weibull wrote:
>> On Fri, Feb 13, 2009 at 04:25, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>>
>>> The problem is that $1 is first expanded by the command parser and then
>>> passed to "print".
>>
>>> The (q) tells zsh to insert a backslash before any special characters
>>> that appear in the value of $1, including the backslash in "\n". Then
>>> "print" strips the extra backslashes off again and the final output is
>>> the original string.
>>
>> Couldn't one use the -r switch to print as well?
>
> Well, it can't be used for the whole thing, because some escapes are
> supposed to be used. I tested, and:
>
> preexec () { print -Pn "\e]0;%n@%m: "; print -rn "$1"; print -n "\a" }
>
> does works I'm not really sure why there's a \a at the end anyway. I
> presume this doesn't mean system bell here.
The \a is the endcode for the title setting command, it is just an
arbitrary value really, as much as \e and ] are. That said, I don't
think this command works if you put literal \a on your command line.
This is what I use:
#for changing a *term title
function ct() {
local MATCH
if [[ "$1" = "-e" ]]; then
#nulls terminate the string when printed, so change them
printf '\e]0;%s\007' ${${${2//$'\x00'/\^@}//
/\\n}//(#m)[$'\x00'-$'\x1f']/$'\x16'$MATCH}
elif [[ "$1" = "-t" ]]; then
pts="$2"
ct -e "$3" > /dev/pts/$pts
else
ct -e "$*"
fi
}
To be honest, I can't say off hand what all those parts do, they're
sort of stacked on top of eachother until it stopped letting anything
through.
My actual preexec() calls it like this:
if [ "$#1" -gt 512 ];then 1=${1[1,512]}; fi
ct -e "$TTY:t [$1] {`print -P "%100<...<%~%<<"`} `strftime "%x %T"
$EPOCHSECONDS`"
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author