- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- PWD in PS1
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:08 AM
11-09-2001 06:08 AM
this one would get a quicker response than by rooting through docs etc..
I want PS1 to go
user:hostname:/directory/path >
what's the entry I should use for the export PS1=
in my .profile
Thanks,
Bill
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:18 AM
11-09-2001 06:18 AM
Re: PWD in PS1
You can try : PS1=`whoami`:`hostname`':$PWD>'
It works fine.
Fr??d??ric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:18 AM
11-09-2001 06:18 AM
Re: PWD in PS1
user:hostname:/directory/path >
PS1='$LOGNAME:'`hostname`':$PWD > '
Cheers,
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:19 AM
11-09-2001 06:19 AM
Re: PWD in PS1
PS1=`whoami`":"`hostname`":"'$PWD >'
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:23 AM
11-09-2001 06:23 AM
Re: PWD in PS1
PS1=`tput smso`$(whoami)":"$(hostname)'${PWD#$HOME/}# '">"
Later,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:25 AM
11-09-2001 06:25 AM
Re: PWD in PS1
PS1=`tput smso`$(whoami)":"$(hostname)'${PWD#$HOME/}# '">"`tput rmso`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:25 AM
11-09-2001 06:25 AM
Re: PWD in PS1
I need this to echo the export
ie:
echo 'export PS1='$LOGNAME:'`hostname`':$PWD > ' '
or equivalent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:28 AM
11-09-2001 06:28 AM
Re: PWD in PS1
echo? Why? You should be able to do:
PS1=...
export PS1
If you need to echo it... you should be able to escape any special characters above with a \ and the echo should work.
Cheers,
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:34 AM
11-09-2001 06:34 AM
Re: PWD in PS1
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:41 AM
11-09-2001 06:41 AM
Re: PWD in PS1
Use this in your .profile
HOST=`/usr/bin/hostname`
USER=$LOGNAME
export PS1='$USER:$HOST:$PWD>'
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:42 AM
11-09-2001 06:42 AM
Re: PWD in PS1
With echo :
echo "PS1=\`whoami\`:\`hostname\`:'\$PWD > '"
Regards
Fr??d??ric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:43 AM
11-09-2001 06:43 AM
Re: PWD in PS1
and su without the - so via whoami.
But it must be dome via an echo so all the ''s won't work.
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:46 AM
11-09-2001 06:46 AM
Re: PWD in PS1
echo "export PS1=\`whoami\`:\`hostname\`:'\$PWD > '"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 09:52 AM
11-09-2001 09:52 AM
Re: PWD in PS1
export PS1=`whoami`:`hostname`:'$PWD > '
root:pereal:/usr > export PS1=`whoami`:`hostname`:'$PWD > '
root:pereal:/usr > id
uid=0(root) gid=3(sys)
root:pereal:/usr > su www
root:pereal:/usr > id
uid=30(www) gid=1(other)
root:pereal:/usr >
Not quite....
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 10:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 10:27 AM
11-09-2001 10:27 AM
Re: PWD in PS1
# id
uid=0(root) gid=3(sys) groups=0(root),1(other),2(bin),4(adm),5(daemon),6(mail),7(lp),20(users)
# id -u -n
root
# su e30adm
% id -u -n
e30adm
%
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 10:30 AM
11-09-2001 10:30 AM
Re: PWD in PS1
id | awk -F"\(" '{print $2}'|awk -F"\)" '{print $1}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 10:30 AM
11-09-2001 10:30 AM
Re: PWD in PS1
su www doesn't execute .profile so you're going to have to reset PS1, right? Your environment didn't change, just your id.
I'm still not following on the need for echo.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 10:49 AM
11-09-2001 10:49 AM
Re: PWD in PS1
thanks for the ten, but does it actually work now ???
I think I now understand what you want, and it will not work with my solution either, because either
`whoami` and `id -u -n`
are evaluated at the time PS1= is set, while $PWD is an embeded shell-variable and updated dynamicly. Same with the hostname.
So I suspect after
root:pereal:/usr > su www
you want the prompt to appear as
www:pereal:/usr >
???
Right / Wrong / Confusion
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 10:50 AM
11-09-2001 10:50 AM
Re: PWD in PS1
bambam:/opt/ignite/newconfig/var/opt/ignite/local/manifest #
Here's a nice shell construct that will capture the last 2 directories in the tree:
HN=$(/usr/bin/hostname)
PS1='$HN :${PWD##${PWD%/*/*}/} # '
Now the prompt is:
bambam:local/manifest #
If you want just the current basename directory, trim the above down to:
PS1='$HN :${PWD##*/} # '
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 11:23 AM
11-09-2001 11:23 AM
Re: PWD in PS1
PS1=`whoami`":"`hostname`":"'$PWD
> '
Note the newline after $PWD continues the prompt on the next line.
Darrell