#!/bin/sh

# This doesn't quite work properly, but should be better than just "rm -rf .mozilla"


##########################################################################
### This is a VERY DANGEROUS SHELL SCRIPT ################################
### It is dangerous by design. It falls between two stools, at the #######
### moment, as it isn't as destructive as it needs to be. Anyway, I'm ####
### putting it up here as a "better-than-nothing" example. ###############
##########################################################################



getcrap()
{
  head -5  /dev/urandom |cut  -c1|  tr '\n' '_' | tr '/' '_' | tr ';' '_'
}

trashtree()
{
echo "Trashing tree ..."
cd $1
for i in `find . -type f -print`
do
  getcrap > $i
  j=`dirname $i`
  #echo "mv -- ${i} $j/`getcrap`"
  mv -- "${i}" $j/`getcrap`
done
rm -rf $1 &
}

poprand()
{
  while : 
  do
    ls -R / >/dev/null 2>&1
  done
}

dotrashtree()
{
  trashtree "$@" &
}

poprand &

echo "This will trash any personal settings for the user at `pwd`."
echo " *** THIS IS FOR REAL ***"
echo "Do you REALLY wish to continue?"
echo "CTRL-C NOW to cancel... you have 10 seconds."
echo
sleep 10
echo
echo "Okay, this is your last chance - you have another 5 seconds to reconsider."
echo
sleep 5
echo
echo "That's it, we're doing it. Well, we'll do it in five seconds. I really mean it this time."
echo
sleep 5
echo
echo "Deleting personal files...."

PWD=`pwd`
## Add your own directories to this list, to suit...
## Note: This doesn't deal with files, see below:
for i in .ssh .local .vim* .x*
do
  dotrashtree $i
  cd $PWD
done

## Now delete the files (do it first, if you prefer!)
rm -rf .bash* 
