Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Unix question: how to display SID and path in prompt
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C24D0B.863A4560
Content-Type: text/plain; charset="iso-8859-1"
Also be aware that when using backticks in your PS1 variable, you are influencing $? as a result.
What happens, is that when you run a command (i.e. "rm
<some_file_that_doesnt_exist>") and then say "echo $?", you are getting the
return code ($?) of your PS1 execution (which is likely to always be 0) -
NOT the $? of the "rm" command.
David Curiel
-----Original Message-----
Sent: Monday, August 26, 2002 10:03 AM
To: Multiple recipients of list ORACLE-L
Put $PWD in there somewhere. I use ${PWD#${PWD%%*([!/])/*([!/])}} to display the last two directory levels, so my prompt never gets TOO long.
The substring extraction of $PWD is ksh specific. You could do it other ways, but this way it uses ksh builtins, so it is _fast_
As an example, when I am in my $ORACLE_HOME, my prompt ends up looking something like:
product/8.1.7 [09:54:42 AM] 181$
where 181 is the current command history number.
Hi!
In my .profile of the oracle user (we're mostly using ksh here), I have set up the prompt that it gives me the host name and database SID.
# always displays host name and Oracle SID as prompt PS1="`hostname`;`echo $ORACLE_SID`$ "
How can I extend this prompt to also include the current directory that I'm in?
e.g. prod1;PCLDB1; u010/app/oracle/admin/PCLDB1
Thanks,
Helmut
------_=_NextPart_001_01C24D0B.863A4560
Content-Type: text/html; charset="iso-8859-1"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Unix question: how to display SID and path in prompt</TITLE>
<META content="MSHTML 5.50.4134.600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=351281414-26082002><FONT face=Arial color=#0000ff size=2>Also
be aware that when using backticks in your PS1 variable, you are
influencing $? as a result. </FONT></SPAN></DIV>
<DIV><SPAN class=351281414-26082002><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=351281414-26082002><FONT face=Arial color=#0000ff size=2>What
happens, is that when you run a command (i.e. "rm
<some_file_that_doesnt_exist>") and then say "echo $?", you are getting
the return code ($?) of your PS1 execution (which is likely to always be 0) -
NOT the $? of the "rm" command.</FONT></SPAN></DIV>
<DIV><SPAN class=351281414-26082002><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=351281414-26082002><FONT face=Arial color=#0000ff size=2>David
Curiel</FONT></SPAN></DIV>
<DIV><SPAN class=351281414-26082002><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Philip Douglass
[mailto:philipd_at_sirs.com]<BR><B>Sent:</B> Monday, August 26, 2002 10:03
AM<BR><B>To:</B> Multiple recipients of list ORACLE-L<BR><B>Subject:</B> Re:
Unix question: how to display SID and path in prompt<BR><BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Put $PWD in there somewhere. I use
${PWD#${PWD%%*([!/])/*([!/])}} to display the last two directory levels, so my
prompt never gets TOO long.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>The substring extraction of $PWD is ksh
specific. You could do it other ways, but this way it uses ksh builtins, so it
is _fast_</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>As an example, when I am in my $ORACLE_HOME, my
prompt ends up looking something like: </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>product/8.1.7 [09:54:42 AM] 181$ </FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>where 181 is the current command historynumber.</FONT></DIV>
<DIV><BR></DIV> <P><FONT size=2>Hi!</FONT> </P> <P><FONT size=2>In my .profile of the oracle user (we're mostly using kshhere), I have set up the prompt that it gives me the host name and database SID.</FONT></P>
<P><FONT size=2># always displays host name and Oracle SID as prompt</FONT> <BR><FONT size=2>PS1="`hostname`;`echo $ORACLE_SID`$ "</FONT> </P> <P><FONT size=2>How can I extend this prompt to also include the currentdirectory that I'm in?</FONT> </P>
<P><FONT size=2>e.g. prod1;PCLDB1; u010/app/oracle/admin/PCLDB1</FONT> </P> <P><FONT size=2>Thanks,</FONT> <BR><FONT size=2>Helmut</FONT>
------_=_NextPart_001_01C24D0B.863A4560--
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Curiel, David INET: david.curiel_at_pioneer.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Mon Aug 26 2002 - 10:23:59 CDT