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
23 echo "De-symlink ~/$dotfile"
29 if [ $BASHRC == "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 echo "Strip dotfiles section from ~/.bashrc"
40 awk "$AWKSCRIPT" ~/.bashrc > bashrc_stripped
42 # see if the stripped file is any different
43 DIFF=`diff ~/.bashrc bashrc_stripped`
44 if [ $? -ne 1 ]; then exit 1; fi # diff failed, bail
45 if [ -n "$DIFF" ]; then
46 echo "Replace ~/.bashrc with stripped version"
48 cp bashrc_stripped ~/.bashrc
50 echo "No dotfiles section in ~/.bashrc"
56 echo "Remove the dotfiles dir $DOTFILES_DIR"