Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Unix question: how to display SID and path in prompt

RE: Unix question: how to display SID and path in prompt

From: Curiel, David <david.curiel_at_pioneer.com>
Date: Mon, 26 Aug 2002 07:23:59 -0800
Message-ID: <F001.004BF92A.20020826072359@fatcity.com>


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,&nbsp; you are influencing $? as a result.&nbsp; </FONT></SPAN></DIV>
<DIV><SPAN class=351281414-26082002><FONT face=Arial color=#0000ff
size=2></FONT></SPAN>&nbsp;</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 &lt;some_file_that_doesnt_exist&gt;") 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>&nbsp;</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>&nbsp;</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>&nbsp;</DIV>   <DIV><FONT face=Arial size=2>The substring extraction&nbsp;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>&nbsp;</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>&nbsp;</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>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>where 181 is the current command history 
  number.</FONT></DIV>
  <BLOCKQUOTE dir=ltr
  style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">     <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>     <DIV
    style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>     <A title=Helmut.Daiminger_at_KirchGruppe.de     href="mailto:Helmut.Daiminger_at_KirchGruppe.de">Daiminger, Helmut</A> </DIV>     <DIV style="FONT: 10pt arial"><B>To:</B> <A title=ORACLE-L_at_fatcity.com     href="mailto:ORACLE-L_at_fatcity.com">Multiple recipients of list ORACLE-L</A>     </DIV>
    <DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, August 26, 2002 9:48     AM</DIV>
    <DIV style="FONT: 10pt arial"><B>Subject:</B> Unix question: how to display     SID and path in prompt</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 ksh 
    here), 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 current 
    directory 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> 

</P></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------_=_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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US