summaryrefslogtreecommitdiff
path: root/.local/bin/config-symlinks
blob: 0831ca33c5ce1dfae77fdeb41b518e61553797bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/bash

sed -e '/^\s*$/d' -e '/#/d' symlinks | while read _target _link; do
	target="$(sed -rn 's|[^/]+/|../|g;s|/[^/]+$|/|p' <<<"$_link")${_target}"
	link="$HOME/$_link"
	if [[ -L "$link" ]]; then
		rm -f "$link"
	fi
	if [[ -e "$link" ]]; then
		echo "ERROR: file exists: $link" >> /dev/stderr
	else
		mkdir -p "${link%/*}"
		ln -s "$target" "$link"
	fi
done