-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
138 lines (107 loc) Β· 6 KB
/
install.sh
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
# -C : Prevent overwriting existing files when redirecting output.
# - Helps to avoid accidentally overwriting files when using
# redirection operators like > or >> in the script.
# -e : Exit the script if any command returns a non-zero status.
# - Ensures the script stops on the first error encountered.
# -u : Exit the script if an undefined variable is used.
# - Prevents running commands with unintended variables.
# -o pipefail : Change pipeline exit status to the last non-zero exit code
# in the pipeline, or zero if all commands succeed.
# - Ensures proper error handling in pipelines.
# -x : (Optional) Enable command tracing for easier debugging.
# - Uncomment this option to debug the script.
set -Ceuo pipefail
# ----------------------------------------------------------------
# utils
# ----------------------------------------------------------------
yellow='\033[1;33m'
reset='\033[0m'
request_admin_privileges() {
if [ "${CI:-false}" = "true" ]; then
return
fi
echo -e "- π¨π»βπ Please enter your password to grant sudo access for this operation"
sudo -v
# Temporarily increase sudo's timeout until the process has finished
(
while true; do
sudo -n true
sleep 60
kill -0 "$$" || exit
done
) 2> /dev/null &
}
# This function installs the Xcode Command Line Tools if they are not already installed.
#
# @See
# https://gist.github.com/mokagio/b974620ee8dcf5c0671f
# http://apple.stackexchange.com/questions/107307/how-can-i-install-the-command-line-tools-completely-from-the-command-line
install_xcode_cli_tools() {
echo -e "π¨π»βπ Install Xcode CLI tools"
echo "- π¨π»βπ Checking Xcode CLI tools..."
# Check if Xcode CLI tools are already installed by trying to print the SDK path.
if xcode-select -p &> /dev/null; then
echo "- π¨π»βπ Xcode CLI tools are already installed"
else
echo "- π¨π»βπ Xcode CLI tools not found. Installing them..."
TEMP_FILE="/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress"
touch "${TEMP_FILE}"
CLI_TOOLS=$(softwareupdate -l \
| grep "\*.*Command Line" \
| tail -n 1 | sed 's/^[^C]* //')
echo "- π¨π»βπ Installing: ${CLI_TOOLS}"
softwareupdate -i "${CLI_TOOLS}" --verbose
rm "${TEMP_FILE}"
fi
echo -e "π¨π»βπ Xcode CLI tools are ready to go π"
}
open_config_apps() {
if [ "$CI" = "true" ]; then
echo "Running in CI environment - skipping app opening"
return
fi
echo "π¨π»βπ Open the apps that needs to be configured"
open -b com.apple.systempreferences
open "/Applications/Google Drive.app"
open "/Applications/Google Chrome.app"
open "/Applications/Raycast.app"
open "/Applications/1Password.app"
open "/Applications/Karabiner-Elements.app"
open /users
open https://github.com/nozomiishii/dotfiles
echo "π¨π»βπ Please refer to github to set up the launched application"
}
# ----------------------------------------------------------------
# Install
# ----------------------------------------------------------------
echo -e "${yellow}"
cat << EOF
π¨π»βπ Nozomiishii Doting Dotfiles
Get ready for your ultimate Mac setup!
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
EOF
echo -e "${reset}"
request_admin_privileges
install_xcode_cli_tools
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b "$HOME/.local/bin" init --apply nozomiishii --verbose
open_config_apps
echo -e "${yellow}"
cat << EOF
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π All dotfiles installation is now complete π
π¨π»βπ Restart your mac to reflect the settings. Happy Codingπ«°π»
run:
sudo reboot
EOF
echo -e "${reset}"