-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·84 lines (67 loc) · 2.41 KB
/
setup.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
#!/usr/bin/env zsh
set -euxo pipefail
# ----------------------------------------------------------
# This is the installation script that sets things in motion
# It installs all the required tools and configures them
# As well as copying the dotfiles to the correct locations
# and hooking up with the .zshrc
# ----------------------------------------------------------
export DOT_DIR=~/git/dotfiles
export LOCAL_DOT_DIR=~/.dotfiles.local
export BOOTSTRAP_DIR=${DOT_DIR}/bootstrap
# Install stuff
function init() {
# Configure git
git config --global user.email [email protected]
git config --global user.name "Gigi Sayfan"
git config --global fetch.prune true
# Local dotfiles dir for additions and customizations
mkdir -p "$LOCAL_DOT_DIR"
touch ${LOCAL_DOT_DIR}/paths.txt
touch ${LOCAL_DOT_DIR}/brew.txt
touch ${LOCAL_DOT_DIR}/brew-link.txt
touch ${LOCAL_DOT_DIR}/brew-cask.txt
touch ${LOCAL_DOT_DIR}/git-repos.txt
# Symlink all rc files into the home dir (run commands. See https://en.wikipedia.org/wiki/Run_commands)
for file in ${DOT_DIR}/rcfiles/*(DN); do
if [[ ! -a "${HOME}/${file:t}" ]]; then
ln -s $file ~
fi
done
# Append a call to existing ~/.zshrc to run the dotfiles' .zshrc if needed
source_dotfiles_zshrc_in_zshrc=$(grep 'source "${DOT_DIR}/.zshrc"' ~/.zshrc)
if [[ ! -n "${source_dotfiles_zshrc_in_zshrc}" ]]; then
echo "source ${DOT_DIR}/.zshrc" >>~/.zshrc
fi
## Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
## Install envsubst
curl -L https://github.com/a8m/envsubst/releases/download/v1.2.0/envsubst-`uname -s`-`uname -m` -o envsubst
chmod +x envsubst
sudo mv envsubst /usr/local/bin
# One time thing to access GCR in different regions
yes Y | gcloud auth configure-docker
# Configure macos defaults
source ${BOOTSTRAP_DIR}/macos-defaults.sh
}
function brew_stuff() {
## Add taps with brew
for item in $(cat ${BOOTSTRAP_DIR}/brew-tap.txt); do
brew tap $item
done
## Install stuff with brew
for item in $(cat ${BOOTSTRAP_DIR}/brew.txt); do
brew install $item
done
## Install apps with brew --cask
for item in $(cat ${BOOTSTRAP_DIR}/brew-cask.txt); do
brew install --cask $item
done
}
function post_brew() {
# Set Azure kubelogin. See https://github.com/Azure/kubelogin
kubelogin convert-kubeconfig -l azurecli
}
init
brew_stuff
post_brew