Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Antwort: Setting the terminal title: problem with percent signs
- X-seq: zsh-users 15345
- From: stefan.albert@xxxxxx
- To: Guillaume Brunerie <guillaume.brunerie@xxxxxxxxx>, zsh-users@xxxxxxx
- Subject: Antwort: Setting the terminal title: problem with percent signs
- Date: Wed, 1 Sep 2010 15:14:37 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=spb.de; s=m1; t=1283346881; bh=TWazvKXTJblFXpm3DDZkWyzP/RUVO4KE9jJYIeOJhi8=; h=In-Reply-To:References:To:MIME-Version:Subject:Message-ID:From: Date:Content-Type; b=GcfhsTwgvU+mIvGNSiZ2umdEiKpuyVBEAeMI7v5yrMYRlS8Immp8xoqxsUasNPR1Q l8QI4/G76N+sfYKvIbnoww3iw+G3iHbps7tGA6UhhHbcbHW6iWjZPJZlfsKD2bYdc9 BbM6+lKxudmzMPcnBeOxOGUu5meCCPGdsd4De6Fg=
- In-reply-to: <AANLkTi=oV2M1sQsc8WTPE76rebx6YEbRXs8RE-tOUf5D@xxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <AANLkTi=oV2M1sQsc8WTPE76rebx6YEbRXs8RE-tOUf5D@xxxxxxxxxxxxxx>
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@xxxxxxxxx>
An: zsh-users@xxxxxxx
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author