-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbootstrap.sh
executable file
·116 lines (103 loc) · 3.21 KB
/
bootstrap.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
#!/bin/bash
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
...
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
...
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS=$(uname -s)
VER=$(uname -r)
fi
echo "OS Detected $OS"
echo "OS Version Detected $VER"
# perform apt update if Ubuntu
if [[ $OS == "Ubuntu" ]]; then
echo "Running 'sudo apt update'"
sudo apt update
fi
# Basic git setup
git config --global core.editor "code --wait"
git config --global user.name "Dean Raspa"
shopt -s nocasematch; if [[ "darwin" =~ "$OS" ]]; then
echo "Setting git user.email to [email protected]"
git config --global user.email "[email protected]"
else
echo "Setting git user.email to [email protected]"
git config --global user.email "[email protected]"
fi
# Symlink .zshrc replacing any symlink or file already there
ln -sfv $(pwd)/.zshrc $HOME/.zshrc
ln -sfv $(pwd)/.zprofile $HOME/.zprofile
ln -sfv $(pwd)/.p10k.zsh $HOME/.p10k.zsh
ln -sfv $(pwd)/.kubectl_aliases $HOME/.kubectl_aliases
ln -sfv $(pwd)/.aws_ebsco_aliases $HOME/.aws_ebsco_aliases
# Install or update Homebrew
which brew &>/dev/null
if [[ $? != 0 ]] ; then
# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >> $HOME/.zprofile
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
else
echo "Running 'brew update'"
brew update
fi
# Install all items in the Brewfile
if [[ -f "Brewfile" ]]; then
echo "Brewfile found. Running 'brew bundle'"
brew bundle
fi
# Make sure zsh is listed in /etc/shells
grep -q zsh /etc/shells
if [[ $? != 0 ]] ; then
echo Adding $(which zsh) to /etc/shells
command -v zsh | sudo tee -a /etc/shells
else
echo "ZSH found in /etc/shells"
fi
shopt -s nocasematch; if [[ "darwin" =~ "$OS" ]]; then
DEF_SHELL=$(dscl . -read ~/ UserShell)
else
DEF_SHELL=$(grep "^$(id -un):" /etc/passwd | cut -d : -f 7-)
fi
echo $DEF_SHELL
if [[ $DEF_SHELL =~ "/bin/zsh" ]] ; then
echo "Your default shell is already $(which zsh)"
else
echo "Enter your password to change default shell to $(which zsh)"
chsh -s $(which zsh)
fi
# Install zim
if [[ ! -d "$HOME/.zim" ]] ; then
echo 'Installing zim'
curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
ln -sf $(pwd)/.zimrc $HOME/.zimrc
else
echo "ZIM already installed run 'zimfw install' to update your modules"
fi
# Install or update NVM
if [[ ! -d "$HOME/.nvm" ]] ; then
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | zsh
else
echo "NVM already installed"
fi