From 52c5113a756a79f267cfe64f22329d2923214726 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Tue, 9 Jun 2015 21:13:28 -0400 Subject: Add script to copy dotfiles. --- bin/setup.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 bin/setup.sh 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 -- cgit v1.2.3