diff --git a/dock.sh b/dock.sh index 4df4b71..341df3a 100755 --- a/dock.sh +++ b/dock.sh @@ -1,7 +1,10 @@ #!/usr/bin/env bash +# Root is $DOTPATH if it exists, otherwise the directory of this script +root=$(realpath "${DOTPATH:-$(dirname "$(realpath "$0")")}") + # Source the bash_traceback.sh file -source "$(dirname "$0")/bash_traceback.sh" +source "$root/bash_traceback.sh" ############################################################################### # FUNCTIONS FOR MANIPULATING MACOS DOCK # diff --git a/dotsync.sh b/dotsync.sh index 111d8c7..0ca2665 100755 --- a/dotsync.sh +++ b/dotsync.sh @@ -1,7 +1,10 @@ #!/usr/bin/env bash +# Root is $DOTPATH if it exists, otherwise the directory of this script +root=$(realpath "${DOTPATH:-$(dirname "$(realpath "$0")")}") + # Source the bash_traceback.sh file -source "$(dirname "$0")/bash_traceback.sh" +source "$root/bash_traceback.sh" ############################################################################### # UPDATE DOTFILES # diff --git a/install.sh b/install.sh index 613e964..59a24f4 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,10 @@ #!/usr/bin/env bash +# Root is $DOTPATH if it exists, otherwise the directory of this script +root=$(realpath "${DOTPATH:-$(dirname "$(realpath "$0")")}") + # Source the bash_traceback.sh file -source "$(dirname "$0")/bash_traceback.sh" +source "$root/bash_traceback.sh" ############################################################################### # INSTALL APPS AND PACKAGES # @@ -17,9 +20,12 @@ fi # Ensure yq is installed to parse the apps.toml file if ! command -v yq &> /dev/null; then + echo -e "⬇️ \033[1;34mInstalling yq to parse apps.toml...\033[0m" brew install yq fi +apps_toml="$root/apps.toml" + # Initialize arrays to store installed apps installed_casks=() installed_formulas=() @@ -105,7 +111,7 @@ install () { brew_sync() { local toml_apps - toml_apps=$(yq eval 'to_entries | map(.value | to_entries | map(select(.value == "cask" or .value == "formula") | .key)) | flatten | .[]' apps.toml) + toml_apps=$(yq eval 'to_entries | map(.value | to_entries | map(select(.value == "cask" or .value == "formula") | .key)) | flatten | .[]' "$apps_toml") toml_apps=$(echo "$toml_apps" | sed -E 's|.*/||') # get name from tapped apps (slashes in name) local missing_formulae @@ -141,7 +147,7 @@ brew_sync() { uv_sync() { local toml_apps - toml_apps=$(yq eval 'to_entries | map(.value | to_entries | map(select(.value == "uv") | .key)) | flatten | .[]' apps.toml) + toml_apps=$(yq eval 'to_entries | map(.value | to_entries | map(select(.value == "uv") | .key)) | flatten | .[]' "$apps_toml") local missing_uv_apps missing_uv_apps=$(comm -23 <(uv tool list | awk '{print $1}' | grep -v '^-*$' | sort) <(echo "$toml_apps" | sort)) @@ -170,7 +176,7 @@ uv_sync() { mas_sync() { local toml_apps - toml_apps=$(yq eval 'to_entries | map(.value | to_entries | map(select(.value == "mas") | .key)) | flatten | .[]' apps.toml) + toml_apps=$(yq eval 'to_entries | map(.value | to_entries | map(select(.value == "mas") | .key)) | flatten | .[]' "$apps_toml") local installed_mas_apps installed_mas_apps=$(mas list | sed -E 's/^([0-9]+)[[:space:]]+(.*)[[:space:]]+\(.*/\1 \2/' | sort) @@ -216,7 +222,7 @@ populate_installed_apps # Use yq to parse the TOML file and store the output in a variable # shellcheck disable=2016 -parsed_toml=$(yq e 'to_entries | .[] | .key as $category | .value | to_entries[] | [$category, .key, .value] | @tsv' apps.toml) +parsed_toml=$(yq e 'to_entries | .[] | .key as $category | .value | to_entries[] | [$category, .key, .value] | @tsv' "$apps_toml") # Install apps from each category in the apps.toml file current_category="" diff --git a/local.sh b/local.sh index 5ab8a38..b150ea6 100755 --- a/local.sh +++ b/local.sh @@ -1,7 +1,10 @@ #!/usr/bin/env bash +# Root is $DOTPATH if it exists, otherwise the directory of this script +root=$(realpath "${DOTPATH:-$(dirname "$(realpath "$0")")}") + # Source the bash_traceback.sh file -source "$(dirname "$0")/bash_traceback.sh" +source "$root/bash_traceback.sh" ############################################################################### # LOCAL SETTINGS AND VARIABLES # diff --git a/macos.sh b/macos.sh index 02dcbf5..1eea66c 100755 --- a/macos.sh +++ b/macos.sh @@ -1,7 +1,10 @@ #!/usr/bin/env bash +# Root is $DOTPATH if it exists, otherwise the directory of this script +root=$(realpath "${DOTPATH:-$(dirname "$(realpath "$0")")}") + # Source the bash_traceback.sh file -source "$(dirname "$0")/bash_traceback.sh" +source "$root/bash_traceback.sh" echo -e "\033[1;34m💻 Setting macOS preferences...\033[0m" diff --git a/run.sh b/run.sh index dd890dd..13e7faf 100755 --- a/run.sh +++ b/run.sh @@ -1,12 +1,16 @@ #!/usr/bin/env bash +# Root is $DOTPATH if it exists, otherwise the directory of this script +root=$(realpath "${DOTPATH:-$(dirname "$(realpath "$0")")}") + # Source the bash_traceback.sh file -source "$(dirname "$0")/bash_traceback.sh" +source "$root/bash_traceback.sh" ############################################################################### # Install Homebrew # ############################################################################### -echo -e "\033[1;34m🍺 Installing Homebrew...\033[0m" +echo +echo -e "\033[1;33m🍺 Installing Homebrew...\033[0m" if ! command -v brew &> /dev/null; then /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" echo -e "🍻 \033[1;32mHomebrew installed.\033[0m" @@ -17,32 +21,36 @@ fi ############################################################################### # Install dotfiles # ############################################################################### -sleep 1 echo +echo -e "\033[1;33m🚀 Running dotsync.sh...\033[0m" +sleep 1 ./dotsync.sh "${1:-}" ############################################################################### # Local settings and variables # ############################################################################### -sleep 1 echo +echo -e "\033[1;33m🚀 Running local.sh...\033[0m" +sleep 1 ./local.sh "${1:-}" ############################################################################### # macOS preferences # ############################################################################### # sleep 1 -# echo +# echo -e "\033[1;33m🚀 Running macos.sh...\033[0m" # sudo ./macos.sh ############################################################################### # Install apps and software # ############################################################################### -sleep 1 echo -./install.sh "${1:-}" +echo -e "\033[1;33m🚀 Running install.sh...\033[0m" sleep 1 +./install.sh "${1:-}" echo +echo -e "\033[1;33m🚀 Running dock.sh...\033[0m" +sleep 1 ./dock.sh echo