- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: changing the prompt
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
Discussions
Discussions
Forums
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
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
тАО08-23-2002 11:09 AM
тАО08-23-2002 11:09 AM
Re: changing the prompt
me=`who am i | cut -d' ' -f1`
host=`hostname`
PS1='me@$host:$PWD:# '
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2002 11:26 AM
тАО08-23-2002 11:26 AM
Re: changing the prompt
You got it, right on the money! Exactly what I was looking for. I formatted your expression even prettier like this:
export PS1=`hostname`:./'${PWD##*/} > '
Which returns something like this:
myServer:./lastPath > _
And it changes with each cd command.
Cool!
One question:
I've never seen the ##*/ operator, or (or is this a grep expression?) Can you explain how this is working?
Thanks a bunch!!
- Allan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2002 12:20 PM
тАО08-24-2002 12:20 PM
Re: changing the prompt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2002 02:04 PM
тАО08-24-2002 02:04 PM
Re: changing the prompt
export PS1='${PWD##${PWD%/*/*}/}'
Be sure you use single quotes. This will show the current directory and one level up. It's really useful for a short prompt but with a little less ambiguity than just the basename (which bin directory is it?)
BTW: The # and % constructs are specific to POSIX shells such as ksh, bash and the HP POSIX shell. It has to do with pattern matching (shortest or longest, left or right pattern). It's a bit difficult to grasp from the man pages; try a good Korn shell book.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2002 04:00 PM
тАО08-24-2002 04:00 PM
Re: changing the prompt
username@hostname current_working_directory root/non-root sysmbol.
for root a root user, it would look like similar to this:
root@hostname: / #
for a non-root user it would look similar to this:
user1@hostname: user1 $
- « Previous
-
- 1
- 2
- Next »