-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·96 lines (73 loc) · 2.07 KB
/
install
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
#!/usr/bin/env bash
DOTFILES="$(pwd)"
COLOR_GRAY="\033[1;38;5;243m"
COLOR_BLUE="\033[1;34m"
COLOR_GREEN="\033[1;32m"
COLOR_RED="\033[1;31m"
COLOR_PURPLE="\033[1;35m"
COLOR_YELLOW="\033[1;33m"
COLOR_NONE="\033[0m"
title() {
echo -e "\n${COLOR_PURPLE}$1${COLOR_NONE}"
echo -e "${COLOR_GRAY}==============================${COLOR_NONE}\n"
}
error() {
echo -e "${COLOR_RED}Error: ${COLOR_NONE}$1"
exit 1
}
warning() {
echo -e "${COLOR_YELLOW}Warning: ${COLOR_NONE}$1"
}
info() {
echo -e "${COLOR_BLUE}Info: ${COLOR_NONE}$1"
}
success() {
echo -e "${COLOR_GREEN}$1${COLOR_NONE}"
}
get_linkables() {
find -H "$DOTFILES" -maxdepth 3 -name '*.symlink'
}
setup_symlinks() {
title "Creating symlinks"
./run-dotbot
}
setup_homebrew() {
title "Setting up Homebrew"
if test ! "$(command -v brew)"; then
info "Homebrew not installed. Installing."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew bundle
}
function setup_shell() {
title "Configuring shell"
zsh_path="$(which zsh)"
if ! grep "$zsh_path" /etc/shells; then
info "adding $zsh_path to /etc/shells"
echo "$zsh_path" | sudo tee -a /etc/shells
fi
if [[ "$SHELL" != "$zsh_path" ]]; then
chsh -s "$zsh_path"
info "default shell changed to $zsh_path"
fi
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
}
setup_macos() {
title "Configuring macOS"
if [[ "$(uname)" == "Darwin" ]]; then
echo "show hidden files by default"
defaults write com.apple.Finder AppleShowAllFiles -bool true
echo "only use UTF-8 in Terminal.app"
defaults write com.apple.terminal StringEncodings -array 4
echo "Kill affected applications"
for app in Safari Finder Dock Mail SystemUIServer; do killall "$app" >/dev/null 2>&1; done
else
warning "macOS not detected. Skipping."
fi
}
setup_symlinks
setup_homebrew
setup_shell
setup_macos
echo -e
success "Done."