diff --git a/install b/install index 9776db3..4f1d8a5 100755 --- a/install +++ b/install @@ -221,6 +221,7 @@ mkfolder ~/bin # Install scripts lnfile scripts/beep ~/bin/ +lnfile scripts/mlog ~/bin/ lnfile scripts/stardate ~/bin/ lnfile scripts/settitle ~/bin/ lnfile scripts/smartwd ~/bin/ diff --git a/scripts/mlog b/scripts/mlog new file mode 100755 index 0000000..0fe79c9 --- /dev/null +++ b/scripts/mlog @@ -0,0 +1,39 @@ +#!/bin/bash +# Monthly logging script +# Call mlog and it will update a log file + +# Set the default mlog folder +[[ -z $MLOG_FOLDER ]] && MLOG_FOLDER="$HOME/mlog" + +# Make sure that the folder exists +[[ ! -d $MLOG_FOLDER ]] && mkdir -pv $MLOG_FOLDER + +# Make sure that we have a valid TMPDIR +[[ -z $TMPDIR ]] && TMPDIR='/tmp' + +# Make sure that we have a valid EDITOR +[[ -z $EDITOR ]] && EDITOR=vim + +MLOG_HDR='' + +if [[ -x $HOME/bin/stardate ]] +then + [[ -z $MLOG_RANK ]] && MLOG_RANK='Chief Engineer' + + MLOG_HDR="$MLOG_RANK's log, Stardate $($HOME/bin/stardate)\n" +fi + +MLOG_HDR="$MLOG_HDR[$(date)]" + +MLOG_FILE="$TMPDIR/mlog-tmp-$$" + +$EDITOR $MLOG_FILE + +[[ ! -s $MLOG_FILE ]] && exit 0 + +MLOG_LOG="$MLOG_FOLDER/$(date +%Y-%m)" + +echo -e "$MLOG_HDR\n" >> $MLOG_LOG +cat $MLOG_FILE >> $MLOG_LOG +echo -e "\n----------------------------------------\n" >> $MLOG_LOG +