TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

An analog clock in your bash prompt on OS X

35 pointsby psm42about 12 years ago

6 comments

Sephrabout 12 years ago
That is a lot of if statements just to get some directly adjacent unicode characters, which can easily be generated with some simple math.<p>This solution may be a little terse (96 bytes; I wrote it for the 140bytes golfing challenge), but it should help explain how to get the current time's clock character: <a href="https://gist.github.com/eligrey/985721#file-annotated-js" rel="nofollow">https://gist.github.com/eligrey/985721#file-annotated-js</a>
chchabout 12 years ago
Instead of using a very long set of If statements, I think you could just use something like<p><pre><code> a=$((`date +%M`/15));b=$((128335 + `date +%l` +((a*(a**2-39*a+110))/6)));printf '%x' $b; </code></pre> and print the resulting hex's character, no?<p>(I'd finish off the code myself, but I have a bus to catch)<p>Edit: Ah, I see Sephr came prepared. ;)
评论 #5582815 未加载
评论 #5568482 未加载
WestCoastJustinabout 12 years ago
Wondering what this looks like on GNU bash (version 4.2.25 i686-pc-linux-gnu)? Wonder no longer:<p><pre><code> $ ./bashtime.sh 🕤</code></pre>
评论 #5568994 未加载
bajsejohannesabout 12 years ago
Honest question: Do you prefer this to a digital time display? Why?<p>Personally, when it comes to time, I "think" digital.
评论 #5568517 未加载
scottwabout 12 years ago
Is there a particular font that works better than others for this? I've tried all my fixed width fonts and the clock is barely readable in any of them.
评论 #5568289 未加载
imsofutureabout 12 years ago
This is cutesy, but having a timestamp on your prompt is an easy-to-implement sometimes-lifesaver. Highly recommended, one way or another :)
评论 #5568380 未加载
评论 #5568398 未加载
评论 #5568700 未加载