LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 01-16-2004, 10:45 AM   #1
clar77
Member
 
Registered: May 2002
Location: Baltimore,MD
Distribution: RH8.0 FC1/2.6.1 MacOsX 10.3
Posts: 53

Rep: Reputation: 15
Terminal titles, KDE, Gnome etc...


Just an informational sort of question here:

Does anyone know how the current working dir is displayed at the top of the terminal window in some terminal applications ? I know that it can be done with $PS1 at the prompt in bash but how is it constantly updated and sent to the terminal app ?

is some variable set to $pwd and updated with each call of cd ?

I'm curious because I've been playing with aterm and eterm on my mac and linux boxes and was sondering how to get these apps to display a similar window title.

Thanks
 
Old 01-16-2004, 11:44 AM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 57
Set the environment variable $PROMPT_COMMAND. In my ~/.bashrc (which is sourced from .bash_profile so it's always set) I have this:
Code:
# Change the window title of X terminals 
case $TERM in
        xterm*|rxvt|Eterm|eterm|aterm)
                PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
                ;;
        screen)
                PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
                ;;
esac

Håkan
 
Old 01-16-2004, 01:52 PM   #3
clar77
Member
 
Registered: May 2002
Location: Baltimore,MD
Distribution: RH8.0 FC1/2.6.1 MacOsX 10.3
Posts: 53

Original Poster
Rep: Reputation: 15
Thanks that worked great!

So its actually written into the various terminal apps to call that variable each time the directory changes and update the title bar accordingly ?

Thanks again.
 
Old 12-21-2007, 01:58 PM   #4
fvu
LQ Newbie
 
Registered: Nov 2006
Distribution: Ubuntu 7.10
Posts: 28

Rep: Reputation: 15
Yes, it is called each time. From `info bash':

PROMPT_COMMAND
If set, the value is executed as a command prior to issuing each primary prompt.

Alternatively, you can use a bash function `nameTerminal' like this:
Code:
# Set terminal title
# @param string $1  Tab/window title
# @param string $2  (optional) Separate window title
# The latest version of this software can be obtained here:
# http://fvue.nl/wiki/NameTerminal
function nameTerminal() {
    [ "${TERM:0:5}" = "xterm" ]   && local ansiNrTab=0
    [ "$TERM"       = "rxvt" ]    && local ansiNrTab=61
    [ "$TERM"       = "konsole" ] && local ansiNrTab=30 ansiNrWindow=0
        # Change tab title
    [ $ansiNrTab ] && echo -n $'\e'"]$ansiNrTab;$1"$'\a'
        # If terminal support separate window title, change window title as well
    [ $ansiNrWindow -a "$2" ] && echo -n $'\e'"]$ansiNrWindow;$2"$'\a'
} # nameTerminal()
This way, you can set the title manually, whenever you like. Personally, I find it useful the set the title when I change to a project directory only. I've written a `cdp' utility for that; you could put `nameTerminal' in the .cdprc file. See: http://fvue.nl/wiki/Bash:_Change_dir...o_project:_cdp

Freddy Vulto
http://fvue.nl
 
  


Reply


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
Xserver has only failsafe terminal on FC2 gnome and KDE gone sueno Fedora 2 04-10-2005 10:29 PM
CLI to Gnome terminal, in KDE.? Carpinus Linux - Newbie 11 03-08-2005 11:56 AM
Alternative terminal to konsole & gnome-terminal Adony Linux - Software 3 10-08-2004 04:59 AM
KDE konsole - Gnome-terminal language encoding or keytab thk33 Linux - Software 3 09-19-2004 04:59 PM
How do I log-out from KDE or Gnome using the Terminal Riichard Linux - Newbie 1 07-07-2004 09:27 AM


All times are GMT -5. The time now is 10:08 AM.

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