aboutsummaryrefslogblamecommitdiffstats
path: root/contrib/hooks/post-save
blob: 6113ce63218cb09c0d1658fbb71559d33f8deefb (plain) (tree)
1
2
3
4
5
6
7
8
9
10

         




                                                                               


                                                                 

                     
 
                                                             

                          















                                                                               
  
#!/bin/sh
#
# This is an example hook. It does two things whenever you save the data files:
#
# 1. Make a commit if the calcurse data directory contains a Git repository.
# 2. Synchronize with a CalDAV server if calcurse-caldav is configured.
#
# In order to install this hook, copy this file to
# $XDG_CONFIG_HOME/calcurse/hooks/ (~/.config/calcurse/hooks/) or
# ~/.calcurse/hooks/ if using ~/.calcurse.

cd "$HOME"/.calcurse/

# Do not do anything when synchronizing with a CalDAV server.
[ -f caldav/lock ] && exit

# If the data directory is under version control, create a Git commit.
if [ -d .git -a -x "$(which git)" ]; then
	git add apts conf keys todo
	if ! git diff-index --quiet --cached HEAD; then
		git commit -m "Automatic commit by the post-save hook"
	fi
fi

# Optionally run the CalDAV synchronization script in the background.
if [ -d caldav -a -x "$(which calcurse-caldav)" ]; then
	(
		date="$(date +'%b %d %H:%M:%S')"
		echo "$date Running calcurse-caldav from the post-save hook..."
		calcurse-caldav
		echo
	) >>caldav/log 2>&1 &
fi