about summary refs log tree commit diff
path: root/configs/setup_configs.sh
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2017-06-23T17·01-0400
committerWilliam Carroll <wpcarro@gmail.com>2017-06-23T17·01-0400
commitf344f2e370fbf88a0306b6a01c99f386a13953c7 (patch)
tree81c19178bdc8986b59d3bca5e91efd9f01690941 /configs/setup_configs.sh
parente51d11e4bc344f624ec90afd299ac1dcb5e6e1fb (diff)
Adds os detection for bootstrapping configs
Diffstat (limited to 'configs/setup_configs.sh')
-rwxr-xr-xconfigs/setup_configs.sh87
1 files changed, 36 insertions, 51 deletions
diff --git a/configs/setup_configs.sh b/configs/setup_configs.sh
index 734acedf428f..28dceff38126 100755
--- a/configs/setup_configs.sh
+++ b/configs/setup_configs.sh
@@ -1,62 +1,47 @@
 #!/usr/bin/env bash
 
-
 pc_settings_path="${HOME}/pc_settings"
+configs_dir="${pc_settings_path}/configs"
+shared_configs="${configs_dir}/shared"
 
+if [[  $(uname) == 'Darwin' ]]; then
+    os_specific_configs="${configs_dir}/os_x"
+elif [[ $(uname) == 'Linux' ]]; then
+    os_specific_configs="${configs_dir}/linux"
+fi
 
-config_files=( \
-  ".zsh_profile" \
-  ".tmux.conf" \
-  ".ctags" \
-  ".vimrc" \
-  ".emacs" \
-)
 
+function symlink_configs () {
+    configs_dir=$1
 
-for i in {1..5}; do
-    cf="${config_files[i]}"
-    echo "\"${cf}\": "
+    for cf in $(find $configs_dir -type f -name ".*"); do
+        filename=$(grep -o "[^\/]+$" <<<$cf)
+        echo "$filename: "
 
-    if [ -f "${HOME}/${cf}" ] && [ ! -L "${HOME}/${cf}" ]; then
-        echo -n "Backing up ${cf} ... " && \
-        mv "${HOME}/${cf}" "${HOME}/${cf}.bak" && \
-        echo "Done."
-    fi
+        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}/${cf}" ]; then
-        if [ $(readlink "${HOME}/${cf}") = "${pc_settings_path}/configs/${cf}" ]; then
-            echo "Already properly symlinked to \"${pc_settings_path}/configs\"."
+        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 "Already symlinked but NOT to the proper location. Aborting..."
+            echo -n "Symlinking to ${filename} ... " && \
+            ln -s $cf "${HOME}/${filename}" && \
+            echo "Done."
         fi
-    else
-        echo -n "Symlinking to ${pc_settings_path}/configs/${cf} ... " && \
-        ln -s "${pc_settings_path}/configs/${cf}" "${HOME}/${cf}" && \
-        echo "Done."
-    fi
-    echo ""
-done
-
-
-# Fish Shell is a special case
-# cf_dir="${HOME}/.configs/fish"
-# cf="config.fish"
-
-# if [ -f "${cf_dir}/${cf}" ] && [ ! -L "${cf_dir}/${cf}" ]; then
-#     echo -n "Backing up ${cf} ... " && \
-#     mv "${cf_dir}/${cf}" "${HOME}/${cf}.bak" && \
-#     echo "Done."
-# fi
-
-# if [ -L "${cf_dir}/${cf}" ]; then
-#     if [ $(readlink "${cf_dir}/${cf}") = "${pc_settings_path}/configs/${cf}" ]; then
-#         echo "Already properly symlinked to \"${pc_settings_path}/configs\"."
-#     else
-#         echo "Already symlinked but NOT to the proper location. Aborting..."
-#     fi
-# else
-#     echo -n "Symlinking to ${pc_settings_path}/configs/${cf} ... " && \
-#     ln -s "${pc_settings_path}/configs/${cf}" "${cf_dir}/${cf}" && \
-#     echo "Done."
-# fi
-# echo ""
+        echo ""
+    done
+}
+
+
+# handle shared configs
+symlink_configs $shared_configs
+
+# handle os-specific configs
+symlink_configs $os_specific_configs