zsh-users
 help / color / mirror / code / Atom feed
From: stefan.albert@spb.de
To: Guillaume Brunerie <guillaume.brunerie@gmail.com>, zsh-users@zsh.org
Subject: Antwort: Setting the terminal title: problem with percent signs
Date: Wed, 1 Sep 2010 15:14:37 +0200	[thread overview]
Message-ID: <28256_1283346880_4C7E51C0_28256_605_1_OF07499B87.DB9CC3E6-ONC1257791.004883C8-C1257791.0048C01D@nbg.sdv.spb.de> (raw)
In-Reply-To: <AANLkTi=oV2M1sQsc8WTPE76rebx6YEbRXs8RE-tOUf5D@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1108 bytes --]

Hi,

you have to substitute the % with %%

Change the line : __last_cmd=$1
in something like that: __last_cmd=`echo $1 | sed -e "s/%/%%/g"`

this should do the job.

Stefan




Von:    Guillaume Brunerie <guillaume.brunerie@gmail.com>
An:     zsh-users@zsh.org
Datum:  19.08.2010 16:51
Betreff:        Setting the terminal title: problem with percent signs



Hi,

I have the following in my .zshrc which set the terminal title to "*cmd"
when cmd is executed and to "(cmd)" when execution of cmd is over.

__last_cmd=
preexec () {
    __last_cmd=$1
    print -Pn "\e]0;*$__last_cmd\a"
}
precmd () {
    if [[ -n $__last_cmd ]]
    then
        print -Pn "\e]0;($__last_cmd)\a"
    fi
}


(print -Pn "\e]0;$str\a"  change the terminal title to $str, see 'man
console_codes')
It works well, except when there are percent signs in the last command.
For example if I type "echo 100%", the terminal title becomes "(echo 100)"
instead of "(echo 100%)" and the string " ]0;*echo 100100%" appears in the
terminal.

How can I do to make it work even with percent signs in the command?

Thank you

Guillaume Brunerie


      parent reply	other threads:[~2010-09-01 13:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-19 14:26 Guillaume Brunerie
2010-08-19 15:05 ` Mikael Magnusson
2010-08-19 15:19   ` Guillaume Brunerie
2010-09-01 13:14 ` stefan.albert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=28256_1283346880_4C7E51C0_28256_605_1_OF07499B87.DB9CC3E6-ONC1257791.004883C8-C1257791.0048C01D@nbg.sdv.spb.de \
    --to=stefan.albert@spb.de \
    --cc=guillaume.brunerie@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).