<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Current date &amp;amp; time in posix shell prompt in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007889#M98946</link>
    <description>I can not seem to find the right PS1 form to show the current time within the command prompt.&lt;BR /&gt;&lt;BR /&gt;Every time I set it, I get the time in the prompt, but it does not change.&lt;BR /&gt;I want the time to be dynamic and reflect the current time when the command prompt is displayed.&lt;BR /&gt;&lt;BR /&gt;Any ideas???</description>
    <pubDate>Tue, 10 Oct 2006 16:02:25 GMT</pubDate>
    <dc:creator>Jaris Detroye</dc:creator>
    <dc:date>2006-10-10T16:02:25Z</dc:date>
    <item>
      <title>Current date &amp; time in posix shell prompt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007889#M98946</link>
      <description>I can not seem to find the right PS1 form to show the current time within the command prompt.&lt;BR /&gt;&lt;BR /&gt;Every time I set it, I get the time in the prompt, but it does not change.&lt;BR /&gt;I want the time to be dynamic and reflect the current time when the command prompt is displayed.&lt;BR /&gt;&lt;BR /&gt;Any ideas???</description>
      <pubDate>Tue, 10 Oct 2006 16:02:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007889#M98946</guid>
      <dc:creator>Jaris Detroye</dc:creator>
      <dc:date>2006-10-10T16:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: Current date &amp; time in posix shell prompt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007890#M98947</link>
      <description>Hi Jaris,&lt;BR /&gt;&lt;BR /&gt;you must escape date command in PS1 to be run every time, when PS1 is displayed: &lt;BR /&gt;&lt;BR /&gt;export PS1=`hostname`" ""\$(date )"#&lt;BR /&gt;&lt;BR /&gt;cheers,&lt;BR /&gt;ivan</description>
      <pubDate>Tue, 10 Oct 2006 16:26:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007890#M98947</guid>
      <dc:creator>Ivan Krastev</dc:creator>
      <dc:date>2006-10-10T16:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Current date &amp; time in posix shell prompt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007891#M98948</link>
      <description>I just cut &amp;amp; pasted your PS1 string into my unix shell, and since the $ is escaped it simply prints the string $(date) in the prompt is does not substitute the value.&lt;BR /&gt;With the PS1 string: &lt;BR /&gt;PS1=`hostname`" ""\$(date)"# &lt;BR /&gt;&lt;BR /&gt;This is what I get:&lt;BR /&gt;saturn $(date)#&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 10 Oct 2006 16:38:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007891#M98948</guid>
      <dc:creator>Jaris Detroye</dc:creator>
      <dc:date>2006-10-10T16:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Current date &amp; time in posix shell prompt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007892#M98949</link>
      <description>Oops, its my fault - i tested it in ksh.&lt;BR /&gt;&lt;BR /&gt;ivan</description>
      <pubDate>Tue, 10 Oct 2006 17:11:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007892#M98949</guid>
      <dc:creator>Ivan Krastev</dc:creator>
      <dc:date>2006-10-10T17:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Current date &amp; time in posix shell prompt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007893#M98950</link>
      <description>Hi Jaris,&lt;BR /&gt;modify your ~/.profile to include:&lt;BR /&gt;ENV=~/.shrc&lt;BR /&gt;export ENV&lt;BR /&gt;&lt;BR /&gt;then edit/create your ~/.shrc to include:&lt;BR /&gt;export DATE="$(date '+%d%b')"&lt;BR /&gt;export SECONDS="$(date '+3600*%H+60*%M+%S')"&lt;BR /&gt;typeset -Z2 _h; typeset -Z2 _m ; typeset -Z2 _s&lt;BR /&gt;_hh="(SECONDS/3600)%24"&lt;BR /&gt;_mm="(SECONDS/60)%60"&lt;BR /&gt;_ss="(SECONDS)%60"&lt;BR /&gt;_time='${_x[(_m=_mm)==(_h=_hh)==(_s=_ss)]}$_h:$_m:$_s'&lt;BR /&gt;export PS1=$(echo "${DATE}${_time} # ")&lt;BR /&gt;set +u&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Oct 2006 02:49:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007893#M98950</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-10-11T02:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: Current date &amp; time in posix shell prompt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007894#M98951</link>
      <description>Wow.  (Pause...)&lt;BR /&gt;&lt;BR /&gt;That's some script.&lt;BR /&gt;Work's great!&lt;BR /&gt;As I try to dissect it to understand exactly what is going on here, I can't seem to understand why the 'export SECONDS=' line produce a dynamic variable that changes every time you reference it.&lt;BR /&gt;I tried the date command with a (less complicated) formatted output string, and it produced a static output not changing until the variable is explicitly set again.  &lt;BR /&gt;&lt;BR /&gt;Why is this different?</description>
      <pubDate>Wed, 11 Oct 2006 08:44:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007894#M98951</guid>
      <dc:creator>Jaris Detroye</dc:creator>
      <dc:date>2006-10-11T08:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Current date &amp; time in posix shell prompt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007895#M98952</link>
      <description>Jaris,&lt;BR /&gt;a quick search of the archive brought the solution:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1017839" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1017839&lt;/A&gt;&lt;BR /&gt;Its the re-evaluation of time that makes the difference to just using `date`.&lt;BR /&gt;&lt;BR /&gt;Script just needed a bit of adjusting.</description>
      <pubDate>Wed, 11 Oct 2006 08:50:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007895#M98952</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-10-11T08:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: Current date &amp; time in posix shell prompt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007896#M98953</link>
      <description>Hi Jaris:&lt;BR /&gt;&lt;BR /&gt;David Totsch explained the logic of this solution in this thread:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=38457&amp;amp;admit=-682735245+1160574500123+28353475" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=38457&amp;amp;admit=-682735245+1160574500123+28353475&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 11 Oct 2006 08:56:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007896#M98953</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-10-11T08:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Current date &amp; time in posix shell prompt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007897#M98954</link>
      <description>Thanks for the pointer, I did not come across that thread researching this issue.&lt;BR /&gt;&lt;BR /&gt;I live for these things, my boss thinks it's a waste of time to obsess over these geek things, but this will give me some food for thought to distract me the rest of the day.&lt;BR /&gt;&lt;BR /&gt;Thanks!!!</description>
      <pubDate>Wed, 11 Oct 2006 09:10:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007897#M98954</guid>
      <dc:creator>Jaris Detroye</dc:creator>
      <dc:date>2006-10-11T09:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Current date &amp; time in posix shell prompt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007898#M98955</link>
      <description>The only modification I made is to include the current path by changing the following line:&lt;BR /&gt;&lt;BR /&gt;export PS1=$(echo "${DATE}${_time}")' @ $PWD #'&lt;BR /&gt;&lt;BR /&gt;Thanks for the lession in obscure shell inner workings.</description>
      <pubDate>Wed, 11 Oct 2006 11:40:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-date-amp-time-in-posix-shell-prompt/m-p/5007898#M98955</guid>
      <dc:creator>Jaris Detroye</dc:creator>
      <dc:date>2006-10-11T11:40:47Z</dc:date>
    </item>
  </channel>
</rss>

