Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 04-22-2010, 04:00 AM   #1
LQ Newbie
Registered: Apr 2010
Posts: 2

Rep: Reputation: 0
set terminal-title dynamically

Hello Folks, this is my first post here.

i googled the problem for about 4 hours
i asked several coders/admins
i searched
and got no satisfying answer

my problem:
- i log into many linux servers (redhat, debian, suse, ubuntu)
- i want to set the terminal window/tab title to something like:

the partial solution i found:
- declaring a function _setTitle() in /etc/bashrc
- setting PROMPT_COMMAND at all servers in /etc/bashrc, calling _setTitle
is /etc/bashrc the proper place?

but i am i need of a command to set the title of the windows/tabs

solution should
- work for tabs and windows
- should use only builtins and avoid nasty cpu-wasting external forks
- work with common clients (windows/putty, linxu/gnome-terminal, linux/konsole)
- solution should base on cli, not on some gui like sshmenu!!!
any ideas?
Old 04-22-2010, 04:13 AM   #2
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian except for netbook still on Slackware 13.37 (and I have to support Ubuntu)
Posts: 8,572
Blog Entries: 30

Rep: Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182
Can be implemented by putting control sequences into the prompt string. The basic concepts (importantly telling the shell not to count the control sequence(s) when calculating the length of the prompt string on-screen) is here.

Regards the control sequences to use, they are specific to the terminal emulator but there is a lot of commonality so you could simply try using xterm title control codes and see if it works.

Vim is clever about setting terminal emulator titles.
Old 04-22-2010, 06:07 AM   #3
LQ Newbie
Registered: Apr 2010
Posts: 2

Original Poster
Rep: Reputation: 0
thx 4 answer
will post the solution here when ready2use
echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"

should work but gnome-terminal immediately deletes the title after it set, argl

Last edited by clifan; 04-22-2010 at 08:31 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you dynamically set the title of new tabs in gnome terminal? hroit Linux - General 9 08-23-2007 03:22 PM
Can you dynamically set the title of new tabs in gnome terminal? hroit Linux - General 1 08-13-2007 04:24 AM
How to change terminal title obnascar Linux - General 1 01-12-2006 02:41 PM
How to set the window title for Eterm dynamically? MiscGeek Linux - Software 4 09-29-2003 09:33 PM

All times are GMT -5. The time now is 04:58 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration