Skip to content

Instantly share code, notes, and snippets.

@oidz1234
Created June 30, 2021 23:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oidz1234/e8d6b3dd6e0f5bd2af00886eff464c16 to your computer and use it in GitHub Desktop.
Save oidz1234/e8d6b3dd6e0f5bd2af00886eff464c16 to your computer and use it in GitHub Desktop.
Tool that I find very helpful and use everyday, can't be that bad if it's just one line right?
#!/bin/bash
# TODO:
# if not args then display notes
notefile="/home/mark/notes.txt"
# this script does not seem safe to me, but if only I use it it's fine, definitly very explotiable though
echo "$(date -Iminutes)" "$@" >> "$notefile"
@neilco
Copy link

neilco commented Jul 1, 2021

Brilliant! Here's my take on your script with the following changes:

  • Output the contents of the note file if no arguments are passed.

  • Updated hardcoded path to note file to use $HOME instead.

  • Updated date command to be more portable

    date under macOS doesn't have a -I option. A portable solution is to use +%FT%H:%M instead.

#!/bin/sh

notefile="$HOME/notes.txt"

if [[ "$#"-eq 0 ]]; then
  cat $notefile
else
  echo "$(date +%FT%H:%M)" "$@" >> "$notefile"
fi

@oidz1234
Copy link
Author

oidz1234 commented Jul 1, 2021

Thank you! I am now using your version :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment