Live data from Hacker News

An analog clock in your bash prompt on OS X

github.com

1–10 of 21 posts

Re: An analog clock in your bash prompt on OS X

#7

This is cutesy, but having a timestamp on your prompt is an easy-to-implement sometimes-lifesaver. Highly recommended, one way or another :)

>one way or another

Speaking of another:

    export PS1="\t $"
For a lot more information on bash prompts, I'd recommend http://blog.sanctum.geek.nz/bash-prompts/

Re: An analog clock in your bash prompt on OS X

#8

This is cutesy, but having a timestamp on your prompt is an easy-to-implement sometimes-lifesaver. Highly recommended, one way or another :)

Out of curiosity, could you describe a scenario where you'd consider time-stamping like that to be a lifesaver?

Re: An analog clock in your bash prompt on OS X

#9
That is a lot of if statements just to get some directly adjacent unicode characters, which can easily be generated with some simple math.

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: https://gist.github.com/eligrey/985721#file-annotated-js

Re: An analog clock in your bash prompt on OS X

#10
Instead of using a very long set of If statements, I think you could just use something like

    a=$((`date +%M`/15));b=$((128335 + `date +%l` +((a*(a**2-39*a+110))/6)));printf '%x' $b;
and print the resulting hex's character, no?

(I'd finish off the code myself, but I have a bus to catch)

Edit: Ah, I see Sephr came prepared. ;)

Post reply on HN