generated from chezmoi/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_once_before_install-packages-darwin.sh.tmpl
35 lines (30 loc) · 1.34 KB
/
run_once_before_install-packages-darwin.sh.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{{- if (eq .chezmoi.os "darwin") -}}
#!/bin/bash
echo "Checking Command Line Tools for Xcode"
# Only run if the tools are not installed yet
# To check that try to print the SDK path
xcode-select -p &> /dev/null
if [ $? -ne 0 ]; then
echo "Command Line Tools for Xcode not found. Installing from softwareupdate…"
# This temporary file prompts the 'softwareupdate' utility to list the Command Line Tools
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
PROD=$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')
softwareupdate -i "$PROD" --verbose;
else
echo "Command Line Tools for Xcode have been installed."
fi
# If Homebrew is not installed on the system, it will be installed here
if test ! $(which brew); then
printf '\n\n\eHomebrew not found. \e[0mInstalling Homebrew...'
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
{{ if eq .chezmoi.arch "arm64" }}
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ${HOME}/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
{{ else if eq .chezmoi.arch "amd64" }}
(echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> ${HOME}/.zprofile
eval "$(/usr/local/bin/brew shellenv)"
{{ end }}
else
printf '\n\n\e[0mHomebrew found. Continuing...'
fi
{{ end -}}