-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.zsh
executable file
·113 lines (99 loc) · 2.77 KB
/
install.zsh
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
#!/usr/bin/env zsh
set -euo pipefail
NON_INTERACTIVE=false
for arg in "$@"; do
if [ "$arg" = "--non-interactive" ]; then
NON_INTERACTIVE=true
break
fi
done
function check_os() {
if [ "$(uname)" != "Darwin" ]; then
echo "This script is only for Mac OS X"
exit 1
else
sleep 1
echo "This OS is Mac OS X!"
fi
if [ "$(uname -m)" != "arm64" ]; then
echo "This Mac is Intel-based!"
echo "This script is only for Apple Silicon"
exit 1
else
sleep 1
echo "This Mac is Apple Silicon!"
fi
}
function clone_repository() {
GITHUB_REPOSITORY="https://github.com/Okabe-Junya/dotfiles"
if [ ! -d "$HOME/dotfiles" ]; then
echo "Cloning dotfiles repository..."
git clone "$GITHUB_REPOSITORY" "$HOME/dotfiles"
else
sleep 1
echo "dotfiles repository is already cloned!"
fi
}
function install_command_line_tools() {
if [ ! -d "/Library/Developer/CommandLineTools" ]; then
echo "Installing Xcode Command Line Tools..."
xcode-select --install 2>/dev/null
else
sleep 1
echo "Xcode Command Line Tools is already installed!"
fi
}
function install_homebrew() {
if [ ! -d "/opt/homebrew" ]; then
echo "Installing Homebrew for Apple Silicon..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 2>/dev/null
else
sleep 1
echo "Homebrew for Apple Silicon is already installed!"
fi
}
function install_oh_my_zsh() {
if [ ! -d "$HOME/.oh-my-zsh" ]; then
echo "Installing Oh My Zsh..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
else
sleep 1
echo "Oh My Zsh is already installed!"
fi
}
function initialize_symbolic_links() {
echo "Initializing symbolic links..."
source "./install/symlink.zsh"
}
function brew_bundle_install() {
echo "Installing Homebrew Bundle..."
current_dir=$(pwd)
cd "$HOME/dotfiles"
if [ "$NON_INTERACTIVE" = true ]; then
echo "Skipping interactive prompt and installing Homebrew Bundle..."
brew bundle install --file="./install/Brewfile"
else
echo -n "Do you want to install Homebrew Bundle? [y/n]: "
read answer
case $answer in
[yY]*)
brew bundle install --file="./install/Brewfile"
;;
*)
echo "Homebrew Bundle is not installed!"
;;
esac
fi
cd "$current_dir"
}
function install() {
check_os
clone_repository
install_command_line_tools
install_homebrew
install_oh_my_zsh
brew_bundle_install
initialize_symbolic_links
echo "Installation is complete!"
}
install