Day Date Time> Instead of $ or # at the terminal

export PS1='\D{%a %D %T}> '

-1
By: hemanth
2009-08-22 08:07:47

These Might Interest You

  • This command displays a clock on your terminal which updates the time every second. Press Ctrl-C to exit. A couple of variants: A little bit bigger text: watch -t -n1 "date +%T|figlet -f big" You can try other figlet fonts, too. Big sideways characters: watch -n 1 -t '/usr/games/banner -w 30 $(date +%M:%S)' This requires a particular version of banner and a 40-line terminal or you can adjust the width ("30" here). Show Sample Output


    45
    watch -t -n1 "date +%T|figlet"
    dennisw · 2009-06-21 01:02:37 9
  • The "date' command has options to easily format the date, day, month, time, etc. But what if you want a relative date or time. Like, I wanted yesterday's date in a particular format. You may want the exact date of "2 months ago" or "-3 days" nicely formatted. For that, you can use this command. The --date option takes fuzzy parameters like the ones mentioned in the previous sentence. Show Sample Output


    2
    date --date=yesterday +%Y%m%d
    vinayv · 2010-09-08 12:29:31 0
  • The end of unix time and the 32bit era will be Tue Jan 19 03:14:07 UTC 2038 . date -ud @$[2**31] date: invalid date `@2147483648' . In 64bit you have much longer, at least to: date -ud @$[2**55] Sun Jun 13 06:26:08 UTC 1141709097 Show Sample Output


    -148
    date -ud @$[2**31-1]
    Escher · 2009-09-11 08:48:50 3
  • If you are stuck behind a firewall and want to synchronize time with another server but you do not want to port forward NTP (which uses UDP) then this command is handy. It gets the time from a server and sets the local time. It is not that accurate but I can live with a second or so drift. Show Sample Output


    1
    date +%Y%m%d%T -s "`ssh user@server 'date "+%Y%m%d %T"'`"
    unixmonkey16473 · 2011-01-11 10:33:32 0

What Others Think

Glad you're enjoying our blog. In future, however, it would be nice if you gave some attribution when you're posting our content here on commandlinefu. This one is from http://blog.commandlinekungfu.com/2009/07/episode-52-prompts-pushing-it.html
Hal_Pomeranz · 461 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: