Can't set titlebar text with ESC sequence

Bug #678322 reported by Akkana Peck on 2010-11-21
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
xterm (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: xterm

I used to be able to change the titlebar inside an xterm window with: echo 'ESC]2;New titleESC' (substitute ^V and the ESC key to insert escape characters; I used a shell alias).

This no longer works, and does nothing; the title remains 'xterm'.

After reading bug 408496, I've tried adding in .Xdefaults:
XTerm*utf8Title: true
XTerm*allowTitleOps: true
but it doesn't help. I've also tried it with XTerm*utf8Title: false since I'm not really clear what that resource is supposed to do. (I'm sending plain ascii for the title, no extra UTF-8 characters, in any case.)

The color prompt code in /root/.bashrc doesn't set the title either:
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'

Is there a new escape sequence for setting the prompt?

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: xterm 256-1ubuntu1
ProcVersionSignature: Ubuntu 2.6.32-26.46-generic-pae 2.6.32.24+drm33.11
Uname: Linux 2.6.32-26-generic-pae i686
Architecture: i386
Date: Sun Nov 21 14:21:04 2010
DkmsStatus: Error: [Errno 2] No such file or directory
MachineType: ECS G41T-M5
ProcCmdLine: root=/dev/sda3 ro
ProcEnviron:
 LC_COLLATE=C
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/usr/bin/tcsh
SourcePackage: xterm
dmi.bios.date: 08/05/2009
dmi.bios.vendor: American Megatrends Inc.
dmi.bios.version: 080015
dmi.board.asset.tag: To Be Filled By O.E.M.
dmi.board.name: G41T-M5
dmi.board.vendor: ECS
dmi.board.version: 1.0
dmi.chassis.asset.tag: To Be Filled By O.E.M.
dmi.chassis.type: 3
dmi.chassis.vendor: ECS
dmi.chassis.version: 1.0
dmi.modalias: dmi:bvnAmericanMegatrendsInc.:bvr080015:bd08/05/2009:svnECS:pnG41T-M5:pvr1.0:rvnECS:rnG41T-M5:rvr1.0:cvnECS:ct3:cvr1.0:
dmi.product.name: G41T-M5
dmi.product.version: 1.0
dmi.sys.vendor: ECS
system:
 distro: Ubuntu
 codename: lucid
 architecture: i686
 kernel: 2.6.32-26-generic-pae

Akkana Peck (akkzilla) wrote :

On Sun, 21 Nov 2010, Akkana Peck wrote:

> Public bug reported:
>
> Binary package hint: xterm
>
> I used to be able to change the titlebar inside an xterm window with:
> echo 'ESC]2;New titleESC' (substitute ^V and the ESC key to insert
> escape characters; I used a shell alias).
>
> This no longer works, and does nothing; the title remains 'xterm'.
>
> After reading bug 408496, I've tried adding in .Xdefaults:
> XTerm*utf8Title: true
> XTerm*allowTitleOps: true
> but it doesn't help. I've also tried it with XTerm*utf8Title: false since I'm not really clear what that resource is supposed to do. (I'm sending plain ascii for the title, no extra UTF-8 characters, in any case.)

Perhaps that's because the Ubuntu package has

*utf8Title: true

so the pattern is already occupied in the resource database.
To override it, you'd have to give a more-specific pattern,
e.g., using "." rather than "*".

(If it's not that simple, I'll dig deeper)

> The color prompt code in /root/.bashrc doesn't set the title either:
> PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
>
> Is there a new escape sequence for setting the prompt?

no - though there is also the allowTitleOps resource from 2007,
with the corresponding menu entry. I don't think anyone's setting
that in a package.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

Akkana Peck (akkzilla) wrote :

Sorry, not that simple. I tried:
xterm.utf8Title: false
xterm.allowTitleOps: true
xterm.title: blah

The xterm.title line was to make sure it was actually checking my .Xdefaults, and it was -- the initial title was "blah", but I still couldn't change it with the escape sequence. Tried both true and false for utf8Title.

Thomas Dickey (dickey-his) wrote :

On Sun, 21 Nov 2010, Akkana Peck wrote:

> Public bug reported:
>
> Binary package hint: xterm
>
> I used to be able to change the titlebar inside an xterm window with:
> echo 'ESC]2;New titleESC' (substitute ^V and the ESC key to insert
> escape characters; I used a shell alias).

That second ESC should be a BEL (the \007 noted below).

I have 10.04, etc., in a VM. I can set the title using vttest (verified
with the xterm #256), but agree that at the bash prompt, that something is
resetting the title.

"set" shows me this string, which is where my title is coming from:

PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

Reading root's .bashrc, I see that it does compute a color prompt, but
then discards that infomation (line 59, "If this is an xterm") by
resetting PS1:

if [ -n "$force_color_prompt" ]; then
     if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
         # We have color support; assume it's compliant with Ecma-48
         # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
         # a case would tend to support setf rather than setaf.)
         color_prompt=yes
     else
         color_prompt=
     fi
fi

if [ "$color_prompt" = yes ]; then
     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\33[01;34m\]\w\[\033[00m\]\$ '
else
     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
     PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
     ;;
*)
     ;;
esac

> This no longer works, and does nothing; the title remains 'xterm'.
>
> After reading bug 408496, I've tried adding in .Xdefaults:
> XTerm*utf8Title: true
> XTerm*allowTitleOps: true
> but it doesn't help. I've also tried it with XTerm*utf8Title: false since I'm not really clear what that resource is supposed to do. (I'm sending plain ascii for the title, no extra UTF-8 characters, in any case.)
>
> The color prompt code in /root/.bashrc doesn't set the title either:
> PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'

probably PS1 is evaluated second - I'd fix it by commenting out the second
assignment to PS1 (and report a bug against bash or whatever is used to
hold these startup scripts).

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

Akkana Peck (akkzilla) wrote :

First, yes, I was using a ^G in the original tests and not a second ESC -- sorry, my typo there.

I just tried it in a vanilla Lucid in a vm, and now I'm even more confused. The standard user's .bashrc can change the titlebar, and here's what it does:
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
If I check by running script, this is echoing
^[]0;user@ubuntu: ~^Guser@ubuntu:~$
as I would expect.

However, if I try to do that myself with echo, it doesn't work:

echo '<ESC>]2;asdf^G'
(typing a ^V before I hit ESC and another one before ^G)

The titlebar doesn't change. I've tried with 0 and 2, with single quotes and double, with bash, tcsh and zsh in case something had changed in the way the shell echoes. No luck with any of them -- titlebar stays unchanged.

Any idea what the difference is between doing this in a bash prompt vs. typing echo in a shell? Typing echo used to work.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers