Skip to content

Instantly share code, notes, and snippets.

@thentenaar
Last active April 8, 2020 20:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thentenaar/2dd7d47a17f6527652dc to your computer and use it in GitHub Desktop.
Save thentenaar/2dd7d47a17f6527652dc to your computer and use it in GitHub Desktop.
A simple script for importing text/calendar files into calcurse
#!/bin/bash
#
# Import text/calendar files from mutt
# to calcurse.
#
# Make sure calcurse is running
if [ ! -f "$HOME/.calcurse/.calcurse.pid" ]; then
exit 1
fi
# Extract the attachments
TEMPDIR=$(mktemp -d add-to-calcurse.XXXXXXXX)
cat "$@" | uudeview -i -m -n -q -p $TEMPDIR - > /dev/null 2>&1
# Add the calendar file (last attachment) to calcurse
FILE=$(ls $TEMPDIR | sort -r | head -1)
calcurse -i "$TEMPDIR/$FILE" > /dev/null 2>&1
# Remove the temporary dir and trigger a reload in calcurse
rm -rf $TEMPDIR > /dev/null 2>&1
kill -USR1 `cat $HOME/.calcurse/.calcurse.pid` > /dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment