-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·129 lines (106 loc) · 3.5 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
#!/bin/bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
# local vars
HOME_ZPROFILE="$HOME/.zprofile"
HOME_ZSHRC="$HOME/.zshrc"
UNAME_MACHINE="$(/usr/bin/uname -m)"
# find the CLI Tools update
echo "Checking for CLI Tool updates..."
PROD=$(softwareupdate -l | grep "\*.*Command Line" | head -n 1 | awk -F"*" '{print $2}' | sed -e 's/^ *//' | tr -d '\n') || true
# install CLIE Tools update
if [[ ! -z "$PROD" ]]; then
softwareupdate -i "$PROD" --verbose
fi
# Check for Homebrew, install if not installed
if test ! $(which brew); then
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "Added Homebrew shell to ${HOME_ZPROFILE}."
echo '# Add Homebrew support' >> ${HOME_ZPROFILE}
# load shellenv for Apple Silicon
if [[ "${UNAME_MACHINE}" == "arm64" ]]; then
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ${HOME_ZPROFILE}
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
# add autocomplete for brew
echo 'FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"' >> ${HOME_ZPROFILE}
fi
# List of packages
PACKAGES=(
bat
coreutils
colordiff
findutils
fzf
gawk
gh
git
grep
gnu-sed
gnu-tar
gnu-indent
gnu-which
jenv
jq
nvm
pyenv
tree
vim
watch
wget
yamllint
zsh
)
echo "Installing packages..."
brew install ${PACKAGES[@]}
# Install The Ultimate vimrc
./templates/vim.sh install
# Install Oh My Zsh
if [[ ! -d "${HOME}/.oh-my-zsh" ]]; then
echo "Installing Oh My Zsh..."
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
# Install Powerlevel10k
if [[ ! -d ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k ]]; then
echo "Installing Powerlevel10k..."
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
sed -i -e 's/ZSH_THEME="\(.*\)"/ZSH_THEME="powerlevel10k\/powerlevel10k"/' ${HOME_ZSHRC}
fi
# Install zsh-autosuggestions
if [[ ! -d ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions ]]; then
echo "Installing zsh-autosuggestions..."
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
fi
# Install zsh-syntax-highlighting
if [[ ! -d ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting ]]; then
echo "Installing zsh-syntax-highlighting..."
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
fi
# Update plugins for Oh My Zsh
if grep -q "plugins=(git)" ${HOME_ZSHRC}; then
# updated plugins
sed -i "" 's/^plugins=(git)/plugins=(\n colorize\n colored-man-pages\n docker\n docker-compose\n fzf\n git\n jenv\n macos\n nvm\n zsh-autosuggestions\n zsh-syntax-highlighting\n)/' ${HOME_ZSHRC}
echo "Updated plugins=(...) in ${HOME_ZSHRC}."
fi
# Update settings for Oh My Zsh
if grep -q "# CASE_SENSITIVE" ${HOME_ZSHRC}; then
sed -i "" 's/# CASE_SENSITIVE/CASE_SENSITIVE/' ${HOME_ZSHRC}
fi
# Add PATHs section to .zshrc
./templates/zshrc-paths.sh
# Install brew cask apps
./templates/brew-casks.sh
# Install JDKs
./templates/jdks.sh
# Create nvm dir
[ -d "$HOME/.nvm" ] || mkdir "$HOME/.nvm"
# Append Aliases section to .zshrc
./templates/zshrc-aliases.sh
# Append Misc section to .zshrc
./templates/zshrc-misc.sh
# Run templates/defaults.sh
./templates/defaults.sh
# Reload zsh
source ~/.zshrc