LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 03-14-2004, 06:43 PM   #1
pvv
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
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,561

Rep: Reputation: 182Reputation: 182
"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.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites

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

Original Poster
Rep: Reputation: 15
jailbait
$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
kolargol
LQ Newbie
 
Registered: Jan 2003
Posts: 25

Rep: Reputation: 0
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:

http://www.ibiblio.org/pub/Linux/doc...mpt-HOWTO.html

it is all explained in there.
 
  


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
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


All times are GMT -5. The time now is 02:45 AM.

Main Menu
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