summaryrefslogtreecommitdiff
path: root/.config/symlinks.sh
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-01-27 16:10:40 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-01-27 17:33:30 -0500
commitf50997ce8bacd444a646c9d62df6847ea6fbe3f1 (patch)
tree13f849100f9ac28216f3b6406fa5896371f56965 /.config/symlinks.sh
parent6a928ec93da30723f950a302cfdd6b3cf3f360d5 (diff)
Create a system for adding symlinks to .config
Diffstat (limited to '.config/symlinks.sh')
-rwxr-xr-x.config/symlinks.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/.config/symlinks.sh b/.config/symlinks.sh
new file mode 100755
index 0000000..a3db6ae
--- /dev/null
+++ b/.config/symlinks.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+sed -e '/^\s*$/d' -e '/#/d' symlinks | while read _path _link; do
+ path="$(sed -rn 's|[^/]+/|../|g;s|/[^/]+$|/|p' <<<"$_link")${_path}"
+ 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 "$path" "$link"
+ fi
+done