-
-
Save slashinfty/86a232586dca8c4859e9078986e69307 to your computer and use it in GitHub Desktop.
Command line split timer - set up as an alias to easily run - removed text pipe option due to poor performance with obs
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
#!/bin/bash | |
alias stimer='shplit' | |
function shplit() { | |
FORMAT="%s.%2N" | |
STARTTIME=$(date +${FORMAT}) | |
function format_duration { | |
printf "%.2f" $1 | |
} | |
function tick_time { | |
DUR=$(format_duration $(bc <<< $(date +${FORMAT})-$STARTTIME)) | |
PRETTY_DUR=$(date +%T.%2N -u -d "@${DUR}") | |
printf "\r%s " ${PRETTY_DUR} | |
} | |
function finish_up { | |
tick_time | |
echo | |
} | |
trap finish_up exit | |
echo "End timing with ctrl-c." | |
while true; do | |
tick_time | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment