diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/setup.sh | 28 |
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 |