../ Front ./ duncan's projects ./ Payphones / ./ TI-calc /
Steampunk Laptop Box Random Search Engine Subversion Home Directory Novatel Merlin

~/ in svn: my svnhome story

Inspired by several other people's stories about keeping their ~/ in a version-control system, I rearranged my home directory and did the same. (For the calendar-obsessed, I did it on 08-Dec-2008.)

I suppose someday I may choose to put some more information here. For the moment, I'm only posting helper scripts that I'm writing.

rm-with-svn.sh

alias rm=~/bin/rm-with-svn.sh and you're in business. This handles the more common options to rm but not all.

#!/bin/bash

function isnt-in-svn () {
  if [ -d ./.svn ] ; then
    return $( [ "X$(svn info $1 2>/dev/null | fgrep Path)X" = "XX" ] ) ;
  else
    return 1
  fi
}

options=0

for P in `getopt --unquoted --options "fRiv" -- $*`
do
  if [ "$options" = "0" ] ; then
    case $P in
	"-f")	force=1 ;;
	"-R")	recurse=1 ;;
	"-i") 	interact=1 ;;
	"-v") 	verbose=1 ;;
	"--") 	options=1 ;;
    esac
  else
      if isnt-in-svn $P ; then
	  if [ "$force" = "1" ] ; then
	      rmopts="f"
	  fi

	  if [ "$recurse" = "1" ] ; then
	      rmopts=$rmopts"R"
	  fi

	  if [ "$interact" = "1" ] ; then
	      rmopts=$rmopts"i"
	  fi

	  if [ "$verbose" = "1" ] ; then
	      rmopts=$rmopts"v"
	  fi

	  if [ ! "$rmopts" = "" ] ; then
	      rmopts="-"$rmopts
	  fi

	  /bin/rm $rmopts "$P"
      else
	  if [ "$verbose" = "1" ] ; then
	      svn rm $P
	  else
	      svn rm -q $P
	  fi
      fi
  fi
done