-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·64 lines (56 loc) · 1.98 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·64 lines (56 loc) · 1.98 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
set -Eeuo pipefail
declare -r DOTFILES_REPO_URL="git@git.greyrock.io:greyrock-labs/dotfiles.git"
function get_os_type() {
uname
}
declare ostype="$(get_os_type)"
if [ "${ostype}" == "Darwin" ]; then
# Install XCode Command Line Tools if necessary
declare git_cmd_path="/Library/Developer/CommandLineTools/usr/bin/git"
if [ ! -e "${git_cmd_path}" ]; then
xcode-select --install
echo "Waiting for Xcode Command Line Tools installation to complete..."
# xcode-select --install returns immediately; poll until the git binary appears.
# Bail after 10 minutes so the script doesn't hang if the user cancels the dialog.
declare -i waited=0
while [ ! -e "${git_cmd_path}" ]; do
if [ "${waited}" -ge 900 ]; then
echo "Timed out waiting for Command Line Tools after 15 minutes." >&2
echo "Please re-run this script after installing them manually (xcode-select --install)." >&2
exit 1
fi
sleep 5
waited+=5
done
echo "Command Line Tools installed."
else
echo "Command line developer tools are already installed."
fi
# Install Homebrew if necessary
export HOMEBREW_CASK_OPTS=--no-quarantine
if which -s brew; then
echo "Homebrew is already installed."
else
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
# Install chezmoi if necessary
if which -s chezmoi; then
echo "Chezmoi is already installed."
else
brew install chezmoi
fi
# Install 1Password if necessary
if which -s op; then
echo "1Password is already installed."
else
brew install --cask 1password
brew install 1password-cli
read -p "Please open 1Password, log into all accounts and set under Settings>CLI activate Integrate with 1Password CLI. Press any key to continue." -n 1 -r
fi
# Apply dotfiles
echo "Applying Chezmoi configuration."
chezmoi init "${DOTFILES_REPO_URL}"
chezmoi apply
fi