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 if [ -z "${DOTFILES_DIR}" ]; then
10 echo 'DOTFILES_DIR is not set. Bailing out.'
14 # See if we've constructed any patched source files that might be
15 # possible link targets
16 if [ ! -d "${DOTFILES_DIR}/patched-src" ]; then
17 echo 'no installed dotfiles to disconnect'
21 DOTFILES_SRC="${DOTFILES_DIR}/patched-src"
22 cd "${DOTFILES_SRC}" || exit 1
24 # See if the bashrc file is involved with dotfiles at all
25 if [ -e '.bashrc' ]; then
32 if [ "${FILE}" = '.' ]; then
35 FILE="${FILE:2}" # strip the leading './'
36 if [ "${DOTFILES_SRC}/${FILE}" -ef ~/"${FILE}" ] && \
37 [ -h ~/"${FILE}" ]; then
39 echo "de-symlink ~/${FILE}"
41 mv "${FILE}" ~/"${FILE}"
45 if [ "${BASHRC}" == 'yes' ]; then
46 echo 'strip dotfiles section from ~/.bashrc'
47 sed '/DOTFILES_DIR/d' ~/.bashrc > bashrc_stripped
49 # see if the stripped file is any different
50 DIFF=$(diff ~/.bashrc bashrc_stripped)
52 if [ ${DIFF_RC} -eq 0 ]; then
53 echo "no dotfiles section found in ~/.bashrc"
55 elif [ ${DIFF_RC} -eq 1 ]; then
56 echo "replace ~/.bashrc with stripped version"
58 mv bashrc_stripped ~/.bashrc
60 exit 1 # diff failed, bail
64 #if [ -d "${DOTFILES_DIR}" ]; then
66 # echo "remove the dotfiles dir ${DOTFILES_DIR}"
67 # rm -rf "${DOTFILES_DIR}"