Extremely simple diet logging from your terminal to stay conscious of what you eat.


~/.functions

function da () {
    local LOG_DIR=~/.diet
    if [ -d $LOG_DIR ]; then
        mkdir -p $LOG_DIR
    fi

    local LOG_FILE=$LOG_DIR/`date +"%Y-%m-%d"`

    if [ $# -eq 1 ]; then
        echo `date +"%H:%M"`" -- $1" >> $LOG_FILE
    elif [ $# -eq 2 ]; then
        echo "$1 -- $2" >> $LOG_FILE
    fi
}

function ds () {
    local LOG_DIR=~/.diet

    if [ $# -eq 0 ]; then
		local LOG_FILE=$LOG_DIR/`date +"%Y-%m-%d"`
        cat $LOG_FILE
    elif [ $# -eq 1 ]; then
        for f in $LOG_DIR/*; do
            echo `basename $f`
            cat $f
        done
    fi
}

Usage

da "10:00" "muesli"
da "pizza"
ds