4 ms·
An analog clock in your bash prompt on OS X
- imsofuture 13y agoThis is cutesy, but having a timestamp on your prompt is an easy-to-implement sometimes-lifesaver. Highly recommended, one way or another :)
- wging 13y ago>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/ http://blog.sanctum.geek.nz/bash-prompts/
- sethhochberg 13y agoOut of curiosity, could you describe a scenario where you'd consider time-stamping like that to be a lifesaver?
- deleted 13y ago[deleted]
- lessnonymous 13y agoI'd love this for its compact nature, but I like digital for its precision. A title tag would be great! <prompt title="12:03:33">(clockface)</prompt>
- scottw 13y agoIs 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.
- psm42 13y agoI use Source Code Pro. Consolas used to be my favorite.
- deleted 13y ago[deleted]
- jnxfgf456 13y agoIt's a digital clock.
- Sephr 13y agoThat 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 https://gist.github.com/eligrey/985721#file-annotated-js
- chch 13y agoInstead 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. ;)
- psm42 13y agoI'm sure you could. It's a quick hack.
- chch 13y agoNo criticism here; your quick hack let me do a quick hack and learn some bash in the process. :)
- deleted 13y ago[deleted]
- nojhan 13y agoI've proposed a PR that do just that (maybe a little bit more readable): https://github.com/paulsm/bashtime/pull/1 https://github.com/paulsm/bashtime/pull/1 Also, the code is now used in the liquid prompt: https://github.com/nojhan/liquidprompt/commit/91959b636af751fefdc5f077464a237b8d4701d2 https://github.com/nojhan/liquidprompt/commit/91959b636af751...
- bajsejohannes 13y agoHonest question: Do you prefer this to a digital time display? Why? Personally, when it comes to time, I "think" digital.
- psm42 13y agoNo idea really. I made it quickly this morning, and I'm trying it out today. It does make it easier to see whether a bunch of commands were performed at roughly the same time than a digital display.
- merlincorey 13y agoYour advantage unfortunately obscures other useful information. My [zsh] prompt displays the exact time down to the second on its own line. I just scan up looking at the time to see if the hours match or minutes... But I still have the ability to know if one was 3 minutes 33 seconds or one was 27 minutes 10 seconds within that hour/half hour.
- WestCoastJustin 13y agoWondering what this looks like on GNU bash (version 4.2.25 i686-pc-linux-gnu)? Wonder no longer: $ ./bashtime.sh 🕤
- ryanpetrich 13y agoA font that supports Emoji is required.