Skip to content

Instantly share code, notes, and snippets.

@defektive
Created August 8, 2017 17:41
Show Gist options
  • Save defektive/b8721313b377138f20c94942cdb12dfd to your computer and use it in GitHub Desktop.
Save defektive/b8721313b377138f20c94942cdb12dfd to your computer and use it in GitHub Desktop.
#! /bin/bash
############################################################
###### ********* Work Log ********** ######
############################################################
## - Manage your daily todos in a nice markdown format
## - Generate a report for [slack|stand]ups
############################################################
ACTION="view"
## Options
##----------------------------------------------------------
while [[ $# -gt 0 ]] ; do
key="$1"
case $key in
## -e | --edit
## Edit your worklog
-e | --edit)
ACTION='edit'
;;
## -r | --report
## generate a report for the last 2 days
-r | --report)
ACTION='report'
;;
##
## -h | --help
## Display this help message
-h | --help)
egrep --color '^#[#-]+' $0
exit 1
break
;;
*)
esac
shift # past argument or value
done
##
##----------------------------------------------------------
## Environment Variables
##----------------------------------------------------------
##
## WLOG_HOME
## Directory for all the wlogs.
## defaults to $HOME/wlog/
if [ -z $WLOG_HOME ]; then
WLOG_HOME="$HOME/wlog/"
fi
function today {
today="$WLOG_HOME`date +%Y-%m-%d.md`"
if [ ! -f $today ]; then
echo "## To Do" > $today
echo >> $today
cat `yesterday` | grep -P '^-' | grep -v '\[x\]' >> $today
fi
echo $today
}
function yesterday {
echo "$WLOG_HOME"`ls $WLOG_HOME | sort | tail -n2 | head -n 1`
}
function report_file {
echo "#" `date --date="$(basename $1 | cut -d. -f 1)" +'%A %B %d, %Y'`
cat $1
echo
echo ------------------
echo
}
function view {
cat `today`
}
function edit {
$EDITOR `today`
}
function report {
today=`today`
yesterday=`yesterday`
report_file $yesterday
report_file $today
}
function print_config {
echo WLOG_HOME $WLOG_HOME;
}
type "$ACTION" 1>/dev/null || exit 1
$ACTION
# the end
##
############################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment