Skip to content

Instantly share code, notes, and snippets.

@myme
Created February 12, 2014 15:11
Show Gist options
  • Save myme/8957226 to your computer and use it in GitHub Desktop.
Save myme/8957226 to your computer and use it in GitHub Desktop.
cscope hook
#!/bin/bash
PIDFILE=.git/cscope.pid
log() {
: # echo "[$$]" $(date +'%F %T'): "$@" >>.git/cscope.log
}
if [ -e $PIDFILE ]; then
PID=$(cat $PIDFILE)
PGRP=$(ps x -o "%p %r" | grep $PID | awk '{print $2}')
log "Killing process group $PGRP"
kill -TERM -$PGRP
fi
echo $$ >.git/cscope.pid
log "Finding files"
find . | egrep '.*\.(c(pp)?|h(pp)?)$' > .git/cscope.files
log "Running cscope"
cscope -i .git/cscope.files -bq
log "Clean up"
rm $PIDFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment