Skip to content

Instantly share code, notes, and snippets.

@fathergoose
Created October 6, 2022 02:40
Show Gist options
  • Save fathergoose/923cdb8f8e8d769ac612a9f3b7671680 to your computer and use it in GitHub Desktop.
Save fathergoose/923cdb8f8e8d769ac612a9f3b7671680 to your computer and use it in GitHub Desktop.
A script for time series journaling (logging)
#!/usr/bin/env zsh
VERSION="0.0.1"
DATE_STORAGE_FMT='%Y-%m-%dT%H:%M:%S'
if [[ $1 == "-h" || $1 == "--help" ]]; then
echo "Usage: $0 [options] [entry]"
echo "Options:"
echo " -h, --help Show this help message and exit"
echo " -v, --version Show program's version number and exit"
exit 0
elif [[ $1 == "-v" || $1 == "--version" ]]; then
echo "$0 $VERSION"
exit 0
fi
# Set the path to the log file
LOGFILE="$HOME/.lgbk"
# If no input is given, list the last 10 entries
if [[ -z $1 ]]; then
tail -n 10 $LOGFILE
else
# If input is given, log the input as an entry
echo "$(date +$DATE_STORAGE_FMT) $1" >> $LOGFILE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment