Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-14-2004, 06:43 PM   #1
LQ Newbie
Registered: Mar 2004
Location: Saint Petersburg, Russia
Distribution: Debian Sarge 3.1
Posts: 25

Rep: Reputation: 15
Question How xterm get known that current dir changed?

I found all linux terminal emulators (xterm, kterminal, gnome's) under Linux RH9 - all they updates titlebars when current dir changed by a command typed.
Have you any idea how they do it (looking from programmer's side) ?

P.S. terminals only interprets incoming text and escape sequences (e.g. color change), and don't know even that bash is used on the server side.
Old 03-14-2004, 08:19 PM   #2
LQ Guru
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Linux Mint 17, Debian 8
Posts: 7,863

Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
"Have you any idea how they do it (looking from programmer's side) ?"

The name of the current directory is kept in a variable called CWD. Try:
echo $CWD

You can use CWD in your script programs to refer to the current working directory. You can use PWD to print your current working directory.

Be prepared. Create a LifeBoat CD.

Steve Stites

Last edited by jailbait; 03-14-2004 at 08:21 PM.
Old 03-15-2004, 06:22 AM   #3
LQ Newbie
Registered: Mar 2004
Location: Saint Petersburg, Russia
Distribution: Debian Sarge 3.1
Posts: 25

Original Poster
Rep: Reputation: 15
$CWD is useful for script writers.
But it'd be very hard to to implement such featur using $CWD:
after ech command input by user xterm should:
1) stop incoming bytes to be reflected on screen
2) send 'echo $CWD' to remote server
3) accept response (/home/user/')
4) start incoming bytes reflecting on the screen

But it's impossible thing, as I know, to recognize when user finished input and when server finished response.

P.S. I may look at source of xterm, but it's very very large, as all useful programms
Old 03-15-2004, 08:27 AM   #4
LQ Newbie
Registered: Jan 2003
Posts: 29

Rep: Reputation: 1
Xterm has no idea that the current directory has changed.
It is the shell that sends the escape sequence telling xterm to modify
the titlebar as part of the prompt.

Have a look at the Bash Prompt Howto:

it is all explained in there.


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
su - and stay in current dir lord-fu Linux - Newbie 2 11-16-2005 08:08 AM
current working directoy is changed if program is loaded through services shahidawan Programming 1 03-31-2005 05:43 AM
Set the Xterm title to reflect the current time ! Bonch Linux - Newbie 11 10-25-2004 04:50 PM
PWD question : Current dir not full path facets Programming 2 06-09-2004 04:58 AM
Prompt w/ current dir and user Jair Slackware 2 03-15-2004 06:16 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:59 AM.

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