about summary refs log tree commit diff
path: root/configs/setup
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2018-07-18T23·53-0400
committerWilliam Carroll <wpcarro@gmail.com>2018-07-19T16·00-0400
commita86c2ddece8fde8a42f1e6031b189d1865b9b211 (patch)
tree77c56fd69f574b697e831fd8c062e7672e342cf2 /configs/setup
parente8ca641075b0acfab44fd424f08ab6fa6f630495 (diff)
Prefer stow over hand-rolled solution
After discovering GNU stow on Nix IRC, refactored install and setup
scripts to consume it.

Code is vastly simplified as a result.
Diffstat (limited to 'configs/setup')
-rwxr-xr-xconfigs/setup44
1 files changed, 4 insertions, 40 deletions
diff --git a/configs/setup b/configs/setup
index e81b49442f42..7b7a814908a3 100755
--- a/configs/setup
+++ b/configs/setup
@@ -1,47 +1,11 @@
 #!/usr/bin/env bash
 
-dotfiles_path="${HOME}/dotfiles"
-configs_dir="${dotfiles_path}/configs"
-shared_configs="${configs_dir}/shared"
+configs="$HOME/dotfiles/configs"
 
 if [[  $(uname) == 'Darwin' ]]; then
-    os_specific_configs="${configs_dir}/os_x"
+  (cd "$configs/os_x" && stow --target="$HOME" *)
 elif [[ $(uname) == 'Linux' ]]; then
-    os_specific_configs="${configs_dir}/linux"
+  (cd "$configs/linux" && stow --target="$HOME" *)
 fi
 
-
-function symlink_configs () {
-    configs_dir=$1
-
-    for cf in $(find $configs_dir -type f -name ".*"); do
-        filename=$(grep -o "[^\/]+$" <<<$cf)
-        echo "$filename: "
-
-        if [ -f "${HOME}/${filename}" ] && [ ! -L "${HOME}/${filename}" ]; then
-            echo -n "Backing up ${filename}... " && \
-            mv "${HOME}/${filename}" "${HOME}/${filename}.bak" && \
-            echo "Done."
-        fi
-
-        if [ -L "${HOME}/${filename}" ]; then
-            if [ $(readlink "${HOME}/${filename}") = $cf ]; then
-                echo "Already properly symlinked to ${configs_dir}."
-            else
-                echo "Already symlinked but NOT to the proper location. Aborting..."
-            fi
-        else
-            echo -n "Symlinking to ${filename}... " && \
-            ln -s $cf "${HOME}/${filename}" && \
-            echo "Done."
-        fi
-        echo ""
-    done
-}
-
-
-# handle shared configs
-symlink_configs $shared_configs
-
-# handle os-specific configs
-symlink_configs $os_specific_configs
+(cd "$configs/shared" && stow --target="$HOME" *)