-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigurator
executable file
·121 lines (101 loc) · 3.34 KB
/
configurator
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
#!/bin/sh
# configurator - System software and environment bootstrapping for macOS.
# TODO: Make this installer script multi-platform and multi-shell compatible.
# Usage message.
usage() {
cat <<EOF
Usage: $0 [OPTIONS]
OPTIONS:
--username, -u <github-username> Specify your GitHub username.
--help, -h Show this help message and exit.
If no username is provided, the script will prompt for it interactively.
For more information, see https://github.com/karimbenbourenane/macos-installer
EOF
}
if [ $# -gt 2 ]; then
echo "Error: Too many arguments. At most two arguments are allowed."
usage
exit 1
fi
# Default GitHub username.
github_username=""
# Parse command-line arguments.
case "$1" in
--username | -u)
shift
github_username="$1"
;;
--help | -h)
usage
exit 0
;;
*)
echo "Invalid option: $1"
usage
exit 1
;;
esac
# If no username is provided, prompt the user.
if [ -z "$github_username" ]; then
echo "Enter your GitHub username: "
read -r github_username
fi
# Begin installation.
echo "Begin system configurator..."
echo "See https://github.com/karimbenbourenane/macos-installer for more info."
# Enable Touch ID for sudo.
echo "Enabling Touch ID for sudo..."
sudo sh -c 'cp /etc/pam.d/sudo_local.template /etc/pam.d/sudo_local'
sudo sh -c 'sed -i "" "s/^#auth/auth/" /etc/pam.d/sudo_local'
# Install chezmoi.
echo "Installing chezmoi and dotfiles..."
sh -c "$(curl -fsLS get.chezmoi.io)" \
-- -b "$(mktemp -d)" init "$github_username" --ssh --apply
# Create XDG directories.
echo "Creating XDG directories..."
mkdir -p "$HOME"/.config
mkdir -p "$HOME"/.local/bin
mkdir -p "$HOME"/.local/share
mkdir -p "$HOME"/.local/state
mkdir -p "$HOME"/.cache/run
# Set Zsh configuration directory globally to use standard XDG location.
# TODO: backup the original file if it already exists.
sudo sh -c 'echo "ZDOTDIR=\"\$HOME\"/.config/shell/zsh" > /etc/zshenv'
# Install Oh My Zsh.
echo "Installing Oh My Zsh..."
export ZDOTDIR="$HOME/.config/shell/zsh"
sh -c "$(curl -fsSL \
https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Install Homebrew.
echo "Installing Homebrew..."
bash -c "$(curl -fsSL \
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install bundles (system packages and desktop applications).
echo "Installing Homebrew bundles..."
$(command -v brew) bundle --file "$HOME/.config/brew/Brewfile" install
# Fix permissions for some Homebrew packages on Apple Silicon.
if [ -d '/opt/homebrew/share' ]; then
echo "Fixing permissions for Homebrew packages..."
chmod -R go-w '/opt/homebrew/share'
fi
# Check local scripts.
echo "Checking local scripts..."
if $(command -v brew) list pycharm >/dev/null 2>&1; then
if [ -f "$HOME/.local/bin/pycharm" ]; then
chmod +x "$HOME/.local/bin/pycharm"
echo "PyCharm script can be found at $HOME/.local/bin/pycharm."
else
echo "PyCharm script is missing from $HOME/.local/bin/pycharm."
fi
else
echo "PyCharm is not installed."
fi
# Install all vim-plug plugins.
echo "Installing vim-plug plugins..."
vi -Esu "$HOME/.config/vim/vimrc" +quitall
# Install Github Copilot for command line.
echo "Installing Github Copilot for command line..."
gh extension install github/copilot-cli --force
# Complete installation.
echo "System configurator completed."
echo "Please open a new shell session to complete the installation."