diff --git a/bin/bin/stoww b/bin/bin/stoww new file mode 100755 index 00000000..38a0ff33 --- /dev/null +++ b/bin/bin/stoww @@ -0,0 +1,39 @@ +#!/bin/sh +# narrow symlinker + +while [ ! -z "$1" ]; do + echo "$1" + cd "$HOME/.dotfiles/$1" + find . -type f | while read -r path; do + target="${HOME}/${path}" + target=$(echo "$target" | sed 's#/\./#/#') + + path="$(pwd)/${path}" + path=$(echo "$path" | sed 's#/\./#/#') + + mkdir -p "$(dirname "$target")" + + if readlink "$target" >/dev/null; then + if [ "$(readlink "$target")" = "$path" ]; then + continue + fi + + rm "$target" + fi + + if [ -f "$target" ]; then + if [ -z "$BS" ]; then + echo "skipping conflict: $target (set BS=t to override)" 1>&2 + continue + fi + + rm "$target" + fi + + echo ln -s "$path" "$target" + ln -s "$path" "$target" + done + + shift + echo +done diff --git a/bootstrap b/bootstrap old mode 100644 new mode 100755 index 2a614d2a..0461a7b3 --- a/bootstrap +++ b/bootstrap @@ -2,18 +2,15 @@ # depends on git, sh. for dir in bin git notes .config; do - mkdir -p "~/$dir" + mkdir -p "$HOME/$dir" done -[ ! -d "~/.dotfiles" ] && git clone "https://github.com/neeasade/dotfiles" "~/.dotfiles" -cd "~/.dotfiles" +[ ! -d "$HOME/.dotfiles" ] && git clone "https://github.com/neeasade/dotfiles" "$HOME/.dotfiles" +cd "$HOME/.dotfiles" +echo >/tmp/stow_conflicts stoww() { - if [ ! -d "~/git/stowsh" ]; then - git clone "https://github.com/neeasade/stowsh" "~/git/stowsh" - fi - - "~/git/stowsh/stowsh" -t .. "$@" + "${HOME}/.dotfiles/bin/bin/stoww" "$@" 2>/tmp/stow_conflicts } core() { @@ -21,7 +18,7 @@ core() { } emacs() { - git clone "https://github.com/neeasade/emacs.d" "~/.emacs.d" + git clone "https://github.com/neeasade/emacs.d" "$HOME/.emacs.d" # initial launch/install packages type emacs >/dev/null 2>&1 && emacs @@ -36,7 +33,7 @@ windows() { # prereq: windows/bootstrap.cmd core - for item in "$(cat ~/.dotfiles/windows/scoop.txt)"; do + for item in "$(cat $HOME/.dotfiles/windows/scoop.txt)"; do scoop install $item done @@ -53,8 +50,13 @@ docker() { [ "$USER" = "emacser" ] && docker +if [ -z "$*" ]; then + echo "options: core, rice, emacs" + exit 1 +fi + # core, emacs, rice, windows -op=${1:-core} -echo bootstrapping $op... -$op -echo done. +echo bootstrapping ${1}... +$1 +cat /tmp/stow_conflicts | grep conflict +echo bootstrapped ${1}...