From 5dfb50aafe1dd1abff30a2425de3ec69ef718a7c Mon Sep 17 00:00:00 2001 From: Max Mulatz Date: Sat, 1 Apr 2023 01:08:49 +0200 Subject: [PATCH] Fix initial setup scenario MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some fixes to problems I ran into on a new initial setup: - Homebrew has a new install script… It requires TTY, so it's hard to run it from another script. - With Homebrew not loaded into the shell via the zprofile file, it's not available in the other topics further down the line. Manually loading it with the `use_brew` helper should fix this - On brand new machines, the `~/.config` directory may not exist, which breaks symlinking there. So create it as part of the `setup` script --- fzf/install | 1 + homebrew/install | 4 ++-- script/lib/utils | 4 ++++ script/setup | 3 +++ zsh/install | 2 ++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fzf/install b/fzf/install index 8ecd8d5..a97ef7d 100755 --- a/fzf/install +++ b/fzf/install @@ -9,6 +9,7 @@ set -o pipefail source "../script/lib/utils" +use_brew brew install fzf info "Install fzf key bindings and completion…" diff --git a/homebrew/install b/homebrew/install index 85a1eb0..dc11220 100755 --- a/homebrew/install +++ b/homebrew/install @@ -13,11 +13,11 @@ source "$SCRIPT_DIR/../script/lib/utils" if ! command -v brew >/dev/null; then info "Install homebrew…" - /usr/bin/env bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + yes "" | INTERACTIVE=1 /usr/bin/env bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" if [ "$(uname -m)" = "arm64" ]; then info "Initialize homebrew shell…" - eval "$(/opt/homebrew/bin/brew shellenv)" + use_brew fi else info "Update homebrew…" diff --git a/script/lib/utils b/script/lib/utils index a947bcf..7c54efe 100644 --- a/script/lib/utils +++ b/script/lib/utils @@ -72,3 +72,7 @@ function create_symlinks() { symlink "$src" "$dest" done } + +function use_brew() { + eval "$(/opt/homebrew/bin/brew shellenv)" +} diff --git a/script/setup b/script/setup index 0585e7a..532cf2e 100755 --- a/script/setup +++ b/script/setup @@ -20,4 +20,7 @@ info "Set name to '$name'…" sudo scutil --set ComputerName "$name" sudo scutil --set LocalHostName "$name" +info "Create ~/.config directory if it does not exist…" +mkdir -p ~/.config + "$SCRIPT_DIR/install" diff --git a/zsh/install b/zsh/install index 24c51d8..2b535d2 100755 --- a/zsh/install +++ b/zsh/install @@ -9,6 +9,8 @@ set -o pipefail source "../script/lib/utils" +use_brew + HOMEBREW_ZSH="$(brew --prefix)/bin/zsh" readonly HOMEBREW_ZSH