Skip to content

Instantly share code, notes, and snippets.

@nrh
Created April 5, 2011 14:45
Show Gist options
  • Save nrh/903731 to your computer and use it in GitHub Desktop.
Save nrh/903731 to your computer and use it in GitHub Desktop.
#!/bin/bash
for file in dot.*; do
dest=`grep '^[\"\#\/].*.file:' "$file"|awk -F'[:\ ]' '{print \$3}'`
dest=$(eval echo $dest)
lwd=${PWD#$HOME/}
if [ -r "${HOME}/${dest}" ]; then
if ! cmp -s "$file" "${HOME}/${dest}"; then
mv "${HOME}/${dest}" "${HOME}/${dest}.orig"
else
rm "${HOME}/${dest}"
fi
fi
dest2=${dest//[^\/]/}
dest2=${dest2/\//..\/}
echo "${HOME}/${dest} -> ${dest2}${lwd}/$file"
ln -s "${dest2}${lwd}/$file" "${HOME}/${dest}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment