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: Steven Lembark <lembark_at_wrkhors.com>
Date: Mon, 26 Aug 2002 06:33:21 -0800
Message-ID: <F001.004BF87A.20020826063321@fatcity.com>

> 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

Back-ticks can be a pain to track, the $() notation in ksh makes things a bit less error prone. Also, no need to echo a variable via shell execution if it is available in the current proc:

    PS1="$(hostname):$ORACLE_SID:\$PWD \$ ";

will give you the full path or

    PS1="$(hostname:$ORACLE_SID:./\${PWD##*/} \$ ";

will give you the relative path (i.e., $PWD stripped of any text leading to a '/').

This is equivalent to bash's:

    PS1='\h:$ORACLE_SID:\W \$ ';

--
Steven Lembark                               2930 W. Palmer
Workhorse Computing                       Chicago, IL 60647
                                            +1 800 762 1582
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Steven Lembark
  INET: lembark_at_wrkhors.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 - 09:33:21 CDT

Original text of this message

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