summaryrefslogtreecommitdiffstats
path: root/godot.sh
blob: 629a1cdf22c50467e5cf69b83d80295fdbd944bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/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

popd >/dev/null

echo
echo "All done. Happy hacking ;)"
echo