Skip to content

Instantly share code, notes, and snippets.

@a0726h77
Created October 23, 2014 05:07
Show Gist options
  • Save a0726h77/45ef304f396d419837b7 to your computer and use it in GitHub Desktop.
Save a0726h77/45ef304f396d419837b7 to your computer and use it in GitHub Desktop.
#!/bin/bash
base='/home/yan/.irssi/irclogs/freenode/#h4'
inotifywait -m -r -e create -e modify -e close_write --exclude "\.git/*" $base | while read res
do
event=`echo $res | awk '{print $2'}`
file=`echo $res | awk '{print $3'}`
echo $res
case "$event" in
CREATE)
# Traitement sur création d'un fichier
echo "new file: $file"
cd $base; \
git add $base/$file; \
git commit -m "new file: $file"
;;
CREATE,ISDIR)
# Traitement sur création d'un répertoire
;;
DELETE)
# Traitement sur suppression d'un fichier
;;
DELETE,ISDIR)
# Traitement sur suppression d'un fichier
;;
MOVED_TO)
# Traitement sur déplacement d'un fichier
;;
MODIFY)
# Traitement sur modification d'un fichier
cd $base; \
git add $base/$file; \
git commit -m "`tail -n 1 $file`"
;;
CLOSE_WRITE,CLOSE)
echo "file change"
cd $base; \
git add $base/$file; \
git commit -m "`tail -n 1 $file`"
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment