Link to home
Start Free TrialLog in
Avatar of 420lou
420lou

asked on

Displaying full path in prompt

This seems like it should be a simple thing to do, but I can't figure out how to display the full current path in the prompt. Using "set prompt="'pwd' " only displays the path of the login directory and never changes. Is there any way that I can have the prompt dynamically display the CURRENT path?
Avatar of ahoffmann
ahoffmann
Flag of Germany image

#if you use csh you need to make an alias like:
   alias mycd '\cd \!$; set prompt = "`pwd`% "'
#if you have tcsh
set prompt = "%B%C2%B\% "
ASKER CERTIFIED SOLUTION
Avatar of yuzh
yuzh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kong
Kong

yuzh's comments work, but how about good old:

export PS1="\$PWD> "

=)
yuzh, %~, %m etc. does not work for csh (as I already said)
Hi  ahoffmann ,

    You are right,  %~, %m etc. does not work for csh on my system, it only work for tcsh.

    But the following will work for csh ( I tested it on Solaris 6/7/8)

     setenv HOSTNAME `hostname`
     set prompt="${LOGNAME}@${HOSTNAME}${PWD} >"

     
> set prompt="${LOGNAME}@${HOSTNAME}${PWD} >"

NO. Except you have a very special csh, then please tell me, I'm interested in: OS, version, etc.
Hi ahoffmann,

   As what I said above, I am using Solaris 5/7/8 (For SPARC SunOS 5.X).

   
NO, deliverd csh with Solaris 5/6 cannot do it as described. Dot.
Yuzh, did you probably have csh linked to tcsh?
Or stupid question: did you try a cd after the setenv?
Avatar of 420lou

ASKER

yuzh,
  the  %~  was really all I was looking for, but you nailed it. Would you happen to know what the code is for a line break. %_ or something of the sort (I'm thinking too DOS here). Actually, do you know where I can just find a full reference of all the usable codes and variable values? I've looked all over the place and came up with next to nothing. Thanks man.
Avatar of 420lou

ASKER

I'm going for:

<~/CURRENT_PATH>
# coomand_goes_here

you know... in case you were wondering...
Hi ahoffmann ,

   I just verify the csh on with Soalris 5 and 7
  set prompt="${LOGNAME}@${HOSTNAME}${PWD} >"

   doesn't work. the prompt does not change after cd !

    It only work for tcsh !

    Thanks.
<~/CURRENT_PATH>
# coomand_goes_here

Ok, you're not using ksh, but here's the ksh equiv to your question:

export PS1=\$PWD'
> '

Yes, extend it to two lines and take it literally...

420lou, already thought about this problem (path too long as prompt), but didn't mention it.
How about using your terminals titlebar for the path, and leaving the prompt as is?
But this needs an alias in all shells.
Which shell are you using, tcsh?
Hi 420lou ,

   Now, I get back to you question. If you want to know the reference setting for promt. you can use "man" to find out the settings for your shell.

   eg.  for tcsh shell,  do:
          man tcsh
         for ksh,   man ksh etc.
         
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- Answered by yuzh

Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster
Cleanup Volunteer
so we agree that %~ (and %m) is the accepted answer
ahoffmann, 420lou said on 09/24/2001 06:22PM PST that it worked for him, so I guess he must be using tcsh. But I don't understand why he didn't accept your first comment as an answer.

On the other hand, you answered his second question. And I'd like to use this thread for a FAQ on setting the prompt, so I'll post a "points for ahoffmann" question.
Answered by yuzh (original recommendation)

SpideyMod
Community Support Moderator @Experts Exchange