Operating System - HP-UX
1753774 Members
7181 Online
108799 Solutions
New Discussion юеВ

Setting prompt to show current directory

 
Frank,Hong
Occasional Advisor

Setting prompt to show current directory

Dear all:
How can I show the current directory beside the prompt?
Should I modify the setting file?How?
Thanks anyway!
13 REPLIES 13
Muthukumar_5
Honored Contributor

Re: Setting prompt to show current directory

You can set it as simply as,

-- /etc/profile --

export PS1='$PWD # '

hth.
Easy to suggest when don't know about the problem!
Slawomir Gora
Honored Contributor

Re: Setting prompt to show current directory

HI,
you can add to .profile

export PS1=`hostname`":"'$PWD'"# "
RAC_1
Honored Contributor

Re: Setting prompt to show current directory

echo $PWD
command-pwd
There is no substitute to HARDWORK
Muthukumar_5
Honored Contributor

Re: Setting prompt to show current directory

If you want temporarily then in shell prompt execute as,

# export PS1='$PWD # '

else user specific then,

put it in $HOME/.profile file.

hth.
Easy to suggest when don't know about the problem!
Yogeeraj_1
Honored Contributor

Re: Setting prompt to show current directory

hi,


we use:
export PS1='K250: ${PWD##/}>'

where my server name is K250

of course, you will have to add the above line in your .profile

hope this helps too!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Muthukumar_5
Honored Contributor

Re: Setting prompt to show current directory

Yogee,

Hope you are great there :)

export PS1='K250: ${PWD##/}>'

You don't want / in pwd ?

Instead you can use as,

export PS1='`hostname`: ${PWD}>' itself. It will help you when changing hostname.

thx.
Easy to suggest when don't know about the problem!
Shweta_3
Occasional Advisor

Re: Setting prompt to show current directory

Hi Frank,

If you are using ksh/bash, you can place the following in the .profile file.
And source the file ". ~/.profile"

The " $' " in the next line is deliberate to get a clean line to type your command, especially if you are deep down your directory!!

export PS1='[$LOGNAME@'`hostname`':$PWD]
$'

Enjoy!!
Ranjith_5
Honored Contributor

Re: Setting prompt to show current directory

Hi,

Add the following entry in /etc/profile

or $HOME/.profile


export PS1="`whoami`@`uname -n` in \$PWD>#"


regards,
Syam
Steve Lewis
Honored Contributor

Re: Setting prompt to show current directory

If you use X windows then you can also set the same details as your window title. Just add this to the end of your ~/.profile ( the ^M is a CTRL-M, got by typing CTRL-V, then CTRL-M, it is not ^ then M.)


function settitle
{
case $TERM in
xterm|dtterm)
echo "\033]0;$1\007\c"
;;
hp*)
echo "\033&f0k${#1}D$1\c"
;;
*)
;;
esac
}
PS1=$(settitle '[$LOGNAME]'`hostname`:'${PWD}')^M'[$LOGNAME]'`hostname`':${PWD}> '