LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-04-2007, 03:07 PM   #1
tschima
Member
 
Registered: Apr 2006
Location: Arizona
Distribution: LinuxMint, NomadBSD, OtherBSD
Posts: 109

Rep: Reputation: 15
Bash Prompt - display correct $(pwd)


When I use $(pwd) in my PS1, whatever the current working dir, the prompt always displays /home/username. However, when I use the \w, I always get the ~ tilde indicating the home dir. Is there a way to get the prompt to indicate that the home dir is /home/username, but always update to display the correct cwd in the prompt? Also, the \W (as opposed to the lowercase \w) doesn't give the whole cwd. Thanks.

Terry
 
Old 07-04-2007, 04:37 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Use single quotes around the prompt so it isn't evaluated before being assigned to PS1

PS1='${PWD}\$ '

or

PS1='$(PWD)\$ '

Last edited by jschiwal; 07-04-2007 at 04:41 PM.
 
Old 07-05-2007, 07:03 PM   #3
tschima
Member
 
Registered: Apr 2006
Location: Arizona
Distribution: LinuxMint, NomadBSD, OtherBSD
Posts: 109

Original Poster
Rep: Reputation: 15
Bash Prompt - display correct $(pwd)

Thanks,

Well, I tried '$(pwd)' and '$(pwd)\$' and it does display the correct current dir, but it also displays the single quotes. I am using bash 2.0.5.08 on RH 7.2 (This is a P1/100 box). I suppose that could have an affect.

Terry
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
correct DISPLAY setting mathfeel Linux - Software 2 05-26-2006 02:15 PM
redirecting the output of pwd into konqueror as a url. using bash fiery_ice Linux - Newbie 5 04-05-2006 03:13 PM
reset pwd to root's current pwd? ataraktos2 Linux - General 10 04-26-2005 04:13 AM
getting custom PWD in bash prompt techrolla Linux - Software 2 08-09-2004 12:39 AM
PC Display Not Correct Mal495 Linux - Newbie 1 10-30-2003 10:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:30 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
Open Source Consulting | Domain Registration