Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Temporarily lock a dynamic terminal title UNIX
This is a follow up on a previous tip to set the terminal title bar to the current working directory. Sometimes, it's useful to lock the title to a description of what you are doing, i.e., something more abstract than the current running job.

Add the following to your aliases.mine file to enable locking the title:
# -- setting the title bar -- 
if ( ${TERM} != "dumb") then
# note, ^[ and ^G are escape characters,
# in vi, ctrl-v, then ctrl-[ or ctrl-G, respectively
alias settitle 'echo -n "^[]2;"\!*"^G"'
# to lock the title, we forget the cwdcmd, and we set
# the title to whatever I typed after "locktitle"
alias locktitle 'unalias cwdcmd; settitle \!*'
# to unlock the title, we set the cwdcmd to
# run settitle as neccesary
alias unlocktitle "alias cwdcmd 'settitle ${HOST} ${cwd}'"
# we start with the titlebar set to the current working dir
# I like my mutt window to say "--- Email by Mutt ---", and
# do other tricks, which I put in a seperate script
alias mutt '${HOME}/scripts/'
Now, whenever I want an abstract title, I type "locktitle THAT TASK I'M WORKING ON", for example "locktitle TESTING THAT SERVER". To get it back to current working directory (or whatever), I do "unlocktitle". Notice the allcaps. I do this way to keep from getting confused.
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)

Temporarily lock a dynamic terminal title | 2 comments | Create New Account
Click here to return to the 'Temporarily lock a dynamic terminal title' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
changing title
Authored by: ateles on Aug 22, '02 10:25:15AM

I tried it but doesn\'t work. Is this supposed to work with
all shells? I am using tcsh. I put the code in .alias. When I type

[plasmo:~] jorge% locktitle Whatever

my propmt changes to

^[]2;Whatever^G[plasmo:~] jorge%


[ Reply to This | # ]
changing title
Authored by: hpdoelle on Aug 22, '02 11:36:53AM

^[ and ^G are control characters! If you just do a copy and paste from the web page, these are no longer control characters, but 2 individual letters. If you edit the alias file with vi, you can get the ^[ with CRTL-v and CRTL-[. The ^G you will get with CTRL-v and CTRL-G.
To be honest, I ran into the same problem until I read the comments from the script.

[ Reply to This | # ]