From 8705a75fba4ccd47badd599e767064b34aef58da Mon Sep 17 00:00:00 2001 From: Ian Adam Naval Date: Wed, 26 Mar 2014 21:18:58 -0400 Subject: [PATCH] Initial commit. --- LICENSE | 21 ++++++++++++++ README.md | 3 ++ install-dotfiles.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100755 install-dotfiles.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1e754d8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) Ian Adam Naval, https://ianonavy.com/ + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..159b805 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Ian's Dotfiles + +Nothing to see here; just my dotfiles. diff --git a/install-dotfiles.sh b/install-dotfiles.sh new file mode 100755 index 0000000..d1a5caf --- /dev/null +++ b/install-dotfiles.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +# +# Symlinks ALL the things! (really just all the .dotfile files) + +set -e + +cd "$(dirname $0)" +export DOTFILES_ROOT="`pwd`" + +create_link () { + ln -s $1 $2 + echo "linked $1 to $2" +} + +overwrite_all=false +backup_all=false +skip_all=false + +for src in `find $DOTFILES_ROOT -name \*.dotfile` +do + dest="$HOME/.`basename \"${src%.*}\"`" + + if [ -f $dest ] || [ -d $dest ] + then + overwrite=false + backup=false + skip=false + + if [ "$overwrite_all" == "false" ] && [ "$backup_all" == "false" ] && [ "$skip_all" == "false" ] + then + echo "conflict adding $dest" + echo "[s]kip, [S]kip all, [o]verwrite, [O]verwrite all, [b]ackup, [B]ackup all: " + echo -n "> " + read -n 1 cmd + echo "" + + case "$cmd" in + o ) overwrite=true;; + O ) overwrite_all=true;; + b ) backup=true;; + B ) backup_all=true;; + s ) skip=true;; + S ) skip_all=true;; + * ) ;; + esac + fi + + if [ "$overwrite" == "true" ] || [ "$overwrite_all" == "true" ] + then + rm -rf $dest + echo "removed $dest" + fi + + if [ "$backup" == "true" ] || [ "$backup_all" == "true" ] + then + mv $dest $dest\.bak + echo "moved $dest to $dest.bak" + fi + + if [ "$skip" == "true" ] || [ "$skip_all" == "true" ] + then + echo "skipped $src" + else + create_link $src $dest + fi + else + create_link $src $dest + fi +done + +find . -name setup.sh | while read setup; do sh -c "${setup}"; done