Created
October 6, 2022 02:40
-
-
Save fathergoose/923cdb8f8e8d769ac612a9f3b7671680 to your computer and use it in GitHub Desktop.
A script for time series journaling (logging)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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