Skip to content

Instantly share code, notes, and snippets.

@msloth
Created April 5, 2022 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msloth/3886f861330cacc3c586781d53a71c7b to your computer and use it in GitHub Desktop.
Save msloth/3886f861330cacc3c586781d53a71c7b to your computer and use it in GitHub Desktop.
Simple time-tracking utility
#------------------------------------------------------------------------------
# time-tag utility
#
# This below goes into your ~/.bashrc
#
# simple utility that appends to a log, to be able to check for how
# long time an activity lasted
#
# usage
# ttag PROJECT ACTIVITY
# eg
# ttag apiary installing tools
# ttag apiary setting up branch and stuff
# ttag lunch
# ttag back
# ttagcat
alias ttag='/cygdrive/c/Dropbox/tools/ttag/ttag.sh'
alias ttagcat='cat /cygdrive/c/Dropbox/tools/ttag/ttag-logfile.txt'
alias ttago='open /cygdrive/c/Dropbox/tools/ttag/ttag-logfile.txt'
#!/bin/sh
#
# simple script to add timestamp to a log to keep track of time
# has two timestamps, first to be able to read quickly, second to
# make it easier to calc timediffs -> activity duration
#
# make an alias
# alias ttag='/cygdrive/c/tools/ttag/ttag.sh'
# alias ttagcat='cat /cygdrive/c/tools/ttag/ttag-logfile.txt'
# then run it like so,
# > ttag project1 isntalling tools
# > ttag project1 conference call
# > ttag lunch
# > ttag -lunch
#
# > ttagcat
# 2017-03-13 11.32.27 - 1489401147: project1 isntalling tools
# 2017-03-13 11.32.28 - 1489401148: project1 conference call
# 2017-03-13 11.32.28 - 1489401148: lunch
# 2017-03-13 11.32.28 - 1489401148: -lunch
#
#
# example log entry
# Mon 2017-03-13 13.37.00 - 143242334211: husq installing tools
# %F full date; same as %Y-%m-%d
# %s seconds since 1970-01-01 00:00:00 UTC
# date +"%F %H.%M.S - %s:"
# specify the logfile
LOGFILE=/cygdrive/c/Dropbox/tools/ttag/ttag-logfile.txt
# timestamp format
TIMESTAMP_NICE=$(date +"%F %H.%M.%S - %s:")
# always append to the logfile
echo $TIMESTAMP_NICE "$@" >> $LOGFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment