3 # You're about to give your sysadmin account to some newbie, and
4 # they'd just be confused by all this efficiency. This script freezes
5 # your dotfiles in their current state and makes everthing look
6 # normal. Note that this will delete your ~/.dotfiles directory, and
7 # strip the .dotfiles portion from your ~/.bashrc file.
9 # See if the bashrc file is involved with .dotfiles at all
10 if [ -e _bashrc ]; then
16 # For each file in this directory.
18 # Create .dotfile version.
21 # Replace symlinks with their target
22 if [ -h ~/$dotfile ]; then
29 if [ $BASH_RC == "yes" ]; then
30 # We may have a dotfiles section in ~/.bashrc. Strip it out.
31 BC="### ---- begin .dotfiles section ---- (keep this magic comment)"
32 EC="### ---- end .dotfiles section ---- (keep this magic comment)"
33 AWKSCRIPT="BEGIN{copy=1}{"
34 AWKSCRIPT="$AWKSCRIPT if(\$0 == \"$BC\"){copy=0};"
35 AWKSCRIPT="$AWKSCRIPT if(\$0 == \"$EC\"){copy=1};"
36 AWKSCRIPT="$AWKSCRIPT if(copy==1 && \$0 != \"$EC\"){print \$0}"
37 AWKSCRIPT="$AWKSCRIPT}"
39 awk "$AWKSCRIPT" ~/.bashrc > bashrc_stripped
41 # see if the stripped file is any different
42 DIFF=`diff ~/.bashrc bashrc_stripped` || exit 1
43 if [ -n "$DIFF" ]; then
45 cp bashrc_stripped ~/.bashrc