{"id":36,"date":"2008-12-30T01:19:18","date_gmt":"2008-12-29T23:19:18","guid":{"rendered":"http:\/\/www.ludovicocaldara.net\/dba\/?p=36"},"modified":"2015-06-05T16:29:40","modified_gmt":"2015-06-05T14:29:40","slug":"tips-bash-prompt-and-oracle","status":"publish","type":"post","link":"https:\/\/www.ludovicocaldara.net\/dba\/tips-bash-prompt-and-oracle\/","title":{"rendered":"Tips: Bash Prompt and Oracle"},"content":{"rendered":"<p>You may want to check the <a href=\"https:\/\/www.ludovicocaldara.net\/dba\/smart-bash-prompt\/\">NEW VERSION of this prompt here.<\/a><\/p>\n<pre class=\"\" lang=\"bash\">export PS1=\\u@\\h:\\w\\$<\/pre>\n<p>I disagree with default bash prompt. Do you? It&#8217;s quote common to work with long paths:<\/p>\n<pre lang=\"bash\">ludovico@host:\/u01\/app\/oracle\/product\/10.2.0\/network\/admin$ \\\r\n\/nooo\/this\/command\/line\/is\/really\/long\/and\/offcourse -I \\\r\n-will -wrap -my -command -line<\/pre>\n<p>and, when working on multi-database environments I need to check my environment:<\/p>\n<pre lang=\"bash\">env | grep -i oracle\r\n#or\r\necho $ORACLE_SID\r\necho $ORACLE_HOME<\/pre>\n<p>I currently use this prompt, instead:<\/p>\n<pre lang=\"bash\">export PS1=$'\\\\n# [ $LOGNAME@\\h:$PWD [\\\\t] [`ohvers` SID:${ORACLE_SID:-\"no sid\"}] ]\\\\n# '\r\n\r\n# [ ludovico@caldara_2k:\/u01\/app\/oracle\/product\/10.2.0\/db_1\/network\/admin [23:15:58] [10.2.0 SID:orcl] ]\r\n#<\/pre>\n<p>What is `<em>ohvers<\/em>`?? I defined this function to get the version of oracle from my ORACLE_HOME variable:<\/p>\n<pre lang=\"bash\">ohvers ()\r\n{\r\necho -n $ORACLE_HOME | sed -n 's\/.*\\\/\\([[:digit:].]\\+\\)\\\/.*\/\\1\/p'\r\n}\r\n<\/pre>\n<p>Pros:<\/p>\n<ul>\n<li>I have a blank line that separate my prompt from previous output<\/li>\n<li>I get the system clock (useful when saving my konsole history. Did I say konsole?)<\/li>\n<li>I can see my Oracle Environment before launching dangerous commands<\/li>\n<li>I have an empty line to start my endless commands<\/li>\n<li>I have a lot of sharps &#8220;#&#8221; : they are fine against wrong copy&amp;paste operations&#8230;<\/li>\n<\/ul>\n<p>Suggestions?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You may want to check the NEW VERSION of this prompt here. 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 &hellip; <a href=\"https:\/\/www.ludovicocaldara.net\/dba\/tips-bash-prompt-and-oracle\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,3],"tags":[26,28,285,9,27],"class_list":["post-36","post","type-post","status-publish","format-standard","hentry","category-linux","category-oracledb","tag-bash","tag-function","tag-linux","tag-oracle","tag-prompt"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":3,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":1036,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/36\/revisions\/1036"}],"wp:attachment":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/media?parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/categories?post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/tags?post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}