- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Equivalent bash shell prompt (linux) in POSIX ...
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
02-02-2001 12:09 AM
02-02-2001 12:09 AM
In linux, I can set the shell prompt as follows:
:
PS1=[\u@\h \W]\$
:
Is there an equivalent for \W in HP-UX POSIX shell ?
Where \W is an escape sequence of the basename of the current working directory.
Rgds,
YC
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2001 12:36 AM
02-02-2001 12:36 AM
Re: Equivalent bash shell prompt (linux) in POSIX shell prompt (HP-UX)
I did not try this with a sh-posix shell, but with a Linux Korn shell (na \\W available either).
Try:
export PS1='[${PWD}]\\$ '
So, use single quotes!
This should put the current working directory in the prompt.
Hope this helps,
Rik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2001 12:38 AM
02-02-2001 12:38 AM
Re: Equivalent bash shell prompt (linux) in POSIX shell prompt (HP-UX)
In the previous version of the forums, a backslash had to be escaped.
That's why you see 2 backslashes in my previous post. It should be just one backslash, of course.
Bye,
Rik.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2001 12:41 AM
02-02-2001 12:41 AM
Re: Equivalent bash shell prompt (linux) in POSIX shell prompt (HP-UX)
This should do the trick !
export PS1="[ $PWD ] "
Good luck !
CvE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2001 12:47 AM
02-02-2001 12:47 AM
Re: Equivalent bash shell prompt (linux) in POSIX shell prompt (HP-UX)
I don't need a full path directory, I only need the last directory of the full path. This can be done in Linux Bash shell with \W.
Rgds,
YC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2001 01:13 AM
02-02-2001 01:13 AM
Re: Equivalent bash shell prompt (linux) in POSIX shell prompt (HP-UX)
Ok this is the thing for the last dir !
export PS1=${PWD##*/}
CvE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2001 01:39 AM
02-02-2001 01:39 AM
Re: Equivalent bash shell prompt (linux) in POSIX shell prompt (HP-UX)
Try this one:
export PS1='[$(basename ${PWD})]\$ '
Mind that the single quotes are required. In the case of double quotes, the value is fix and will not change after a directory change.
Bye,
Rik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2001 01:49 AM
02-02-2001 01:49 AM
Solutionall together there are a lot of options, but I think this is the final one you meant to achieve.
export PS1='[(${PWD##*/})]\$ '
This one will only display the last directory you are in and is changing again when you cd to an other directory.
CvE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2001 05:06 PM
02-02-2001 05:06 PM
Re: Equivalent bash shell prompt (linux) in POSIX shell prompt (HP-UX)
Would you like to share where can I learn these tricks ?
Thanks,
Yc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2001 06:19 PM
02-02-2001 06:19 PM
Re: Equivalent bash shell prompt (linux) in POSIX shell prompt (HP-UX)
Any decent shell programming book -- Korn, Bourne, or POSIX -- will have these "tricks". Another great place to learn shell programming is in HP's POSIX Shell Programming class. Five days of shell tips, tricks, and programs.
--Bruce
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2001 06:48 AM
02-05-2001 06:48 AM
Re: Equivalent bash shell prompt (linux) in POSIX shell prompt (HP-UX)
export VISUAL=emacs
MACHINENAME=`uname -n | cut -d. -f1`
export PS1='$MACHINENAME:$PWD> '
The first line is to use command line editing by pressing ctrl-p and ctrl-n for previous and next command typed. Cursor movement is down by ctrl-f and ctrl-b. I like this one over seting it to vi.
The last 2 lines give you a prompt like
castor:/home/felix>
The path on the prompt will get longer and longer as you go deep into subdirectories.
P.S. There is a ksh in linux distribution, named pdksh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2001 11:28 AM
02-05-2001 11:28 AM
Re: Equivalent bash shell prompt (linux) in POSIX shell prompt (HP-UX)
http://hpux.cs.utah.edu
or you can download and compile it if you like from a number of places.
--Chris