[clue-tech] Note Software?

Keith Christian keith1christian at gmail.com
Wed Aug 19 12:19:45 MDT 2009


Here is a shell script function I wrote that opens a new or existing
text file, appends a timestamp to the end of the file, then opens it
with "vi" with the cursor positioned at the end.

Works with either Linux, Unix, or on Windows with Cygwin as shown below.


today() {
        DESCRIPTION="Move to today's directory, e.g. ~/calendar/2007/10/17"
        NOTES_TXT="notes_`date '+%Y%m%d'`.txt"
        CALENDAR_PARENT_HOME=/cygdrive/c/Documents\ and\
Settings/KChristian/My\ Documents
        TODAY_DIR="${CALENDAR_PARENT_HOME}/calendar/`date '+%Y/%m/%d'`"
        echo -e "\n\n#---Checking for: ${TODAY_DIR}"
        pushd . > /dev/null
        cd
        if [ ! -d "${TODAY_DIR}" ]
        then
                echo
                echo "No directory for today exists: ${TODAY_DIR}"
                echo
                echo "Making one..."
                mkdir -p "${TODAY_DIR}"
                popd > /dev/null
                sleep 1
        fi

        cd "${TODAY_DIR}"
        ls -alrt

        echo >> ${NOTES_TXT}
        echo >> ${NOTES_TXT}
        echo >> ${NOTES_TXT}
        date >> ${NOTES_TXT}
        echo >> ${NOTES_TXT}

        echo -e "\n\n"
        vi + ${NOTES_TXT}
        echo -e "\n\n"
}


A search could be easily added with find and grep if desired.


=======Keith


More information about the clue-tech mailing list