- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Configuring the user command shell 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
Forums
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
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
тАО07-28-2006 03:59 AM
тАО07-28-2006 03:59 AM
Configuring the user command shell prompt
I am running an 11.11 server and would like to have all user prompts at the command shell appear with the directory that the user is currently in at any given time. My plan is to modify the global-cshrc file and/or the users' individual .cshrc files.
My question is, what is the correct syntax to use to accomplish this? Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 04:02 AM
тАО07-28-2006 04:02 AM
Re: Configuring the user command shell prompt
You can search the forum for a lot of solutions or play with it like
export PS1='$PWD >'
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 04:13 AM
тАО07-28-2006 04:13 AM
Re: Configuring the user command shell prompt
set prompt = "$cwd:t %"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 04:15 AM
тАО07-28-2006 04:15 AM
Re: Configuring the user command shell prompt
A Google search yielded the following information from the UNIX FAQ (http://www.faqs.org/faqs/unix-faq/faq/part2/section-4.html).
C Shell (csh):
Put this in your .cshrc - customize the prompt variable the way you want.
alias setprompt 'set prompt="${cwd}% "'
setprompt # to set the initial prompt
alias cd 'chdir \!* && setprompt'
If you use pushd and popd, you'll also need
alias pushd 'pushd \!* && setprompt'
alias popd 'popd \!* && setprompt'
Some C shells don't keep a $cwd variable - you can use `pwd` instead.
If you just want the last component of the current directory in your prompt ("mail% " instead of "/usr/spool/mail% ") you can use
alias setprompt 'set prompt="$cwd:t% "'
Some older csh's get the meaning of && and || reversed. Try doing:
false && echo bug
If it prints "bug", you need to switch && and || (and get a better version of csh.)
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 04:15 AM
тАО07-28-2006 04:15 AM
Re: Configuring the user command shell prompt
The syntax for assigning a value to an environmental variable is unique in csh:
% set prompt="[`whoami`@`hostname`]:`pwd` % "
Adding this to the global cshrc should work, unless a user's local .cshrc overrides it.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 04:16 AM
тАО07-28-2006 04:16 AM
Re: Configuring the user command shell prompt
$cwd:t gives you just the current directory, but $cwd would give you the full path:
testqa1 1: set prompt = "$cwd:t %"
fifejj %pwd
/home/fifejj
fifejj %set prompt = "$cwd %"
/home/fifejj %
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 04:21 AM
тАО07-28-2006 04:21 AM
Re: Configuring the user command shell prompt
since I see the string '.cshrc' in your question, I assume C-Shell.
The prompt is stored in the variable
$prompt.
This is the entry in .cshrc:
set HOST=`uname -n`
if ($?prompt && -f ~/.prompt) then
if ("$prompt" != "") source ~/.prompt
alias cd "cd \!*; source ~/.prompt"
endif
This is my ~/.prompt (see attachment for escape-sequences in strings!!) - note that you can drop the CLEARCASE_STUFF if you dont have that Software:
if ( $?prompt ) then
# better set HOST in .cshrc
# set HOST=`hostname`
if ( $?CLEARCASE_ROOT ) then
if ($?tcsh) then
set icon=${CLEARCASE_ROOT:t}
set ccview=%B${icon}%b:
else
set icon=`basename $CLEARCASE_ROOT`
set ccview=${icon}:
endif
else set ccview= icon=$HOST
endif
if ( $AKTPROJEKT != "keinProjekteingestellt" ) then
set ccview=${AKTPROJEKT}:$ccview
endif
if ( ($TERM == xterm) || ($TERM == dtterm) ) then
set prompt=${LOGNAME}@${HOST}:${ccview}"! "
echo -n ""
else
if ($?tcsh) then
set prompt="${HOST}:${ccview}%~:! "
else
set prompt="${HOST}:${ccview}${cwd}:! "
endif
endif
endif
Note that TCSH (Superset of csh) has really nice and usable capabilities, but my prompt takes care of this.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 04:43 AM
тАО07-28-2006 04:43 AM
Re: Configuring the user command shell prompt
you can man csh for more details.
Also for what its worth, you should not modify individual users .cshrc files. Personally I would be very annoyed if some admin came along and decided what I needed in my .cshrc file. Let the users tend their own .cshrc files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 05:07 AM
тАО07-28-2006 05:07 AM