blob: 3c4a0685683c25f4a1a548a800d71bd8acd1d668 (
plain) (
tree)
|
|
#!/bin/bash
# target dir of dotfiles (relative to $HOME)
TARGET=".dotfiles"
if [[ ! -e "${HOME}/${TARGET}" ]]; then
git clone git://git.animux.de/dotfiles.git "${HOME}/${TARGET}"
fi
pushd $HOME >/dev/null
# create new symlinks as specified in dotfiles mapping file:
grep -v "^#\|^$" "${TARGET}/symlink-mapping" | \
grep "[^ \t]\+ -> [^ \t]\+" | \
awk -F " -> " '{ print $1 ; print "'$TARGET'/"$2; }' | \
while read target ; read source ; do
if [[ -e "${target}" && ! -f "${target}" && ! -L "${target}" ]]; then
echo "!!! ~/${target}/ exists and is not a symlink."
else
# remove folder (only if they are symlinks) and regular files
# (all other actions could be dangerouse: e.g. lost private keys)
[[ -L "${target}" || -f "${target}" ]] && rm -f "${target}"
# create ne symlink
ln -s "${source}" "${target}"
fi
done
# update hash of current symlink mapping
md5sum "${TARGET}/symlink-mapping" > "${TARGET}/management/symlinks.md5"
popd >/dev/null
echo
echo "All done. Happy hacking ;)"
echo
|