<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DBA survival BLOG &#187; Linux</title>
	<atom:link href="http://www.ludovicocaldara.net/dba/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ludovicocaldara.net/dba</link>
	<description>Keep DBA job simple. Thanks.</description>
	<lastBuildDate>Thu, 27 Aug 2009 13:58:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tips: Bash Prompt and Oracle</title>
		<link>http://www.ludovicocaldara.net/dba/tips-bash-prompt-and-oracle/</link>
		<comments>http://www.ludovicocaldara.net/dba/tips-bash-prompt-and-oracle/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 23:19:18 +0000</pubDate>
		<dc:creator>Ludovico</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[prompt]]></category>

		<guid isPermaLink="false">http://www.ludovicocaldara.net/dba/?p=36</guid>
		<description><![CDATA[
export PS1=\u@\h:\w\$

I disagree with default bash prompt. Do you? It&#8217;s quote common to work with long paths:

ludovico@host:/u01/app/oracle/product/10.2.0/network/admin$ \
/nooo/this/command/line/is/really/long/and/offcourse -I \
-will -wrap -my -command -line

and, when working on multi-database environments I need to check my environment:

env &#124; grep -i oracle
#or
echo $ORACLE_SID
echo $ORACLE_HOME

I currently use this prompt, instead:

export PS1=$'\\n# [ $LOGNAME@\h:$PWD [\\t] [`ohvers` SID:${ORACLE_SID:-&#34;no sid&#34;}] ]\\n# '
&#160;
# [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PS1</span>=\u<span style="color: #000000; font-weight: bold;">@</span>\h:\<span style="color: #c20cb9; font-weight: bold;">w</span>\$</pre></div></div>

<p>I disagree with default bash prompt. Do you? It&#8217;s quote common to work with long paths:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ludovico<span style="color: #000000; font-weight: bold;">@</span>host:<span style="color: #000000; font-weight: bold;">/</span>u01<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>product<span style="color: #000000; font-weight: bold;">/</span>10.2.0<span style="color: #000000; font-weight: bold;">/</span>network<span style="color: #000000; font-weight: bold;">/</span>admin$ \
<span style="color: #000000; font-weight: bold;">/</span>nooo<span style="color: #000000; font-weight: bold;">/</span>this<span style="color: #000000; font-weight: bold;">/</span>command<span style="color: #000000; font-weight: bold;">/</span>line<span style="color: #000000; font-weight: bold;">/</span>is<span style="color: #000000; font-weight: bold;">/</span>really<span style="color: #000000; font-weight: bold;">/</span>long<span style="color: #000000; font-weight: bold;">/</span>and<span style="color: #000000; font-weight: bold;">/</span>offcourse <span style="color: #660033;">-I</span> \
<span style="color: #660033;">-will</span> <span style="color: #660033;">-wrap</span> <span style="color: #660033;">-my</span> <span style="color: #660033;">-command</span> <span style="color: #660033;">-line</span></pre></div></div>

<p>and, when working on multi-database environments I need to check my environment:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-i</span> oracle
<span style="color: #666666; font-style: italic;">#or</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$ORACLE_SID</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$ORACLE_HOME</span></pre></div></div>

<p>I currently use this prompt, instead:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PS1</span>=$<span style="color: #ff0000;">'\\n# [ $LOGNAME@\h:$PWD [\\t] [`ohvers` SID:${ORACLE_SID:-&quot;no sid&quot;}] ]\\n# '</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># [ ludovico@caldara_2k:/u01/app/oracle/product/10.2.0/db_1/network/admin [23:15:58] [10.2.0 SID:orcl] ]</span>
<span style="color: #666666; font-style: italic;">#</span></pre></div></div>

<p>What is `<em>ohvers</em>`?? I defined this function to get the version of oracle from my ORACLE_HOME variable:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ohvers <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #007800;">$ORACLE_HOME</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">'s/.*\/\([[:digit:].]\+\)\/.*/\1/p'</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Pros:</p>
<ul>
<li>I have a blank line that separate my prompt from previous output</li>
<li>I get the system clock (useful when saving my konsole history. Did I say konsole?)</li>
<li>I can see my Oracle Environment before launching dangerous commands</li>
<li>I have an empty line to start my endless commands</li>
<li>I have a lot of sharps &#8220;#&#8221; : they are fine against wrong copy&amp;paste operations&#8230;</li>
</ul>
<p>Suggestions?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ludovicocaldara.net/dba/tips-bash-prompt-and-oracle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
