Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 1842  / 3 Years ago, mon, august 23, 2021, 6:14:00

I'm trying to find a way to quickly change the title of a Gnome Terminal 2.32.1 window since I have quite a few open and I'm editing different files in each, using a compiler in one, tailing log files in others and so forth. Hence it's a pain looking for the window I want when they all say pax@pax-desktop:~.



This question led me to try xtitle but, for some reason it's not actually changing the title.



Executing xtitle xyzzy results in no visible feedback but piping it through od confirms it's outputting an escape sequence (which I'm assuming is correct, though I haven't checked in detail):



pax@pax-desktop:~/porn_dir$ xtitle xyzzy | od -xcb
0000000 5d1b 3b32 7978 7a7a 0779 5d1b 3b31 7978
033 ] 2 ; x y z z y a 033 ] 1 ; x y
033 135 062 073 170 171 172 172 171 007 033 135 061 073 170 171
0000020 7a7a 0779
z z y a
172 172 171 007
0000024


I can go into the menu Terminal | Set Title and change it okay from there but I would much prefer a command-line solution since I can do it automatically (such as create a vi alias which sets the title to vi filename before running the editor and resets it on exit).



In the profile preferences, the initial title is set to Terminal and the When terminal commands set their own titles is set to Replace initial title. There's also only the one profile Default which is the one I'm using.


More From » 11.04

 Answers
3

Turns out xtitle is working fine and changing the title. However, there's a section in the default .bashrc as follows:



# 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: wa]$PS1"
;;
*)
;;
esac


which sets the prompt up so that it changes the title back to the usual value every time it asks the user for input.



By commenting the PS1=... line above out, the title remains set to whatever you choose.



This has the side effect of not updating the current user@host status for all terminals. To selectively enable this for just the current shell, before running xtitle use:



export PS1='${debian_chroot:+($debian_chroot)}u@h:w$ '


(Remember, you must source this in the terminal, not call/source from a script!)


[#41104] Tuesday, August 24, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fatuatexen

Total Points: 451
Total Questions: 107
Total Answers: 110

Location: Trinidad and Tobago
Member since Thu, Apr 27, 2023
1 Year ago
fatuatexen questions
;