Skip to content

Instantly share code, notes, and snippets.

@rshipp
Created September 25, 2015 11:44
Show Gist options
  • Save rshipp/e6667c660493cbaa27b8 to your computer and use it in GitHub Desktop.
Save rshipp/e6667c660493cbaa27b8 to your computer and use it in GitHub Desktop.
take daily encrypted notes
#!/bin/bash
# take notes
IDENT= # put your gpg key id (email) here
NOTES_DIR=~/.n
TMP_DIR=/dev/shm/.n
GPG=gpg
mkdir -p "$NOTES_DIR" || exit $?
mkdir -p "$TMP_DIR" || exit $?
date=$(date --iso)
file="$TMP_DIR/$date.md"
efile="$NOTES_DIR/$date.gpg"
if [[ -f $efile ]]; then
$GPG -o "$file" -d "$efile"
$EDITOR "$file"
else
$EDITOR "$file"
fi
while ! $GPG -o "$efile" -er $IDENT "$file"; do
read -p "something went wrong. fix it and hit enter to try again." _
done
rm "$file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment