summaryrefslogtreecommitdiff
path: root/bin/setup.sh
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2015-06-09 21:13:28 -0400
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2015-06-09 21:13:28 -0400
commit52c5113a756a79f267cfe64f22329d2923214726 (patch)
treef90dfaea7d0c1870604db885c78f19fb5d287b4d /bin/setup.sh
parentda708893c29c4982e5e9c7cac72a9849807d2cc6 (diff)
Add script to copy dotfiles.
Diffstat (limited to 'bin/setup.sh')
-rwxr-xr-xbin/setup.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/setup.sh b/bin/setup.sh
new file mode 100755
index 0000000..6d1620d
--- /dev/null
+++ b/bin/setup.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+red='\e[0;31m'
+green='\e[0;32m'
+none='\e[0m'
+
+cd
+# Check that things are in their right places.
+if [[ ! -f dotfiles/bin/setup.sh ]]; then
+ echo -e "${red}[FAIL]${none} expected to find myself"
+ exit 1
+fi
+
+# Creates a symlink with target $1 at location $2.
+# Does nothing and prints an error message if $2 exists and is not a symlink.
+create_symlink() {
+ if [[ -e "$2" && ! -h "$2" ]]; then
+ echo -e "${red}[WARNING]${none} '$2' exists and is not a symlink. Skipped."
+ else
+ if ln -sf "$1" "$2"; then
+ echo -e "${green}[OK]${none} '$2' → '$1'"
+ else
+ echo -e "${red}[WARNING] Could not create '$2'"
+ fi
+ fi
+}
+
+create_symlink dotfiles/gitconfig .gitconfig