Created
April 27, 2011 17:44
-
-
Save markcaudill/944768 to your computer and use it in GitHub Desktop.
Some code that can be used to have your timestamp in your Bash prompt be a stardate.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function stardate() | |
{ | |
# There's apparently no cannon way to calculate the startdate | |
# but here goes. | |
# Add up all the minutes so far in the day, divide by minutes in 24 hours and format it nicely. | |
DECIMAL=$(echo $(( $(date -u '+%H') * 60 + $(date -u '+%M') )) | awk '{printf("%.2f", $1/1440)}' | sed 's/^0*//') | |
# Get the number of days since epoch. | |
DATE=$(( $(date -u '+%s') / 60 / 60 / 24 )) | |
echo "$DATE$DECIMAL" | |
} | |
# This prompt includes the stardate, user@hostname and the current working directory. | |
export PS1="[\$(stardate)][\u@\h \w]\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment