Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: /usr/bin/printf



2009/2/13 Mikael Magnusson <mikachu@xxxxxxxxx>:
> 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}

Well I remember what this part does now, it puts a literal ^V before
every byte between 0 and 0x1f, which is a trick that probably only
works in rxvt-unicode, I have this commented out below which seems to
work more generally:
#   #(q) instead of (V) is also an option
    printf '\e]0;%s\007' ${${2//
/\\n}//(#m)[$'\x00'-$'\x1f']/${(V)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
>



-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author