diff --git a/histd.sh b/histd.sh index 7cb5d3a..a0261f9 100755 --- a/histd.sh +++ b/histd.sh @@ -11,10 +11,9 @@ function _check_editor { fi } +# Create the required directories and open a text editor +# so that the user can describe the day. function edit_note { - # Creates the required directories and opens a text editor - # so that the user can describe the day. - # Create dirs (base_dir/year/month) WORKDIR="$BASE_DIR/$(date +%Y)/$(date +%m)" mkdir -p $WORKDIR @@ -29,8 +28,8 @@ function edit_note { cd - > /dev/null } +# Create an archive with all notes function backup { - # Creates an archive with all notes ARCHIVE_PATH=~/histd-$(date +%F).tar.xz cd $BASE_DIR tar cfJ $ARCHIVE_PATH ../histd @@ -39,16 +38,18 @@ function backup { echo Saved to $ARCHIVE_PATH } +# Concatenate all files and prefix each with the filename. +# The result will be printed to stdout. function merge { - # This function concatenates all files and prefixes each with the filename. - # The result will be printed to stdout. find $BASE_DIR -type f -name "*.md" -exec echo "# {}" \; -exec cat "{}" \; -exec echo \; } +# Display tree of all notes function list { tree $BASE_DIR } +# Open last note function last { _check_editor LAST_FILE=$(ls -t $BASE_DIR/**/**/* | head -1)