-
Notifications
You must be signed in to change notification settings - Fork 9
/
install.sh
executable file
·163 lines (135 loc) · 4.03 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/sh
# add required dependencies
# * GCC
# * python
# * delta
# * bat
# * thefuck
packages=(
"curl",
"git",
"gcc",
"delta",
"bat",
"thefuck",
"python"
"zoxide"
"lazygit"
"ripgrep"
)
exists() {
type "$1" &> /dev/null;
}
install_missing_packages() {
for p in "${packages[@]}"; do
if hash "$p" 2>/dev/null; then
echo "$p is installed"
else
echo "$p is not installed"
# Detect the platform (similar to $OSTYPE)
OS="`uname`"
case $OS in
'Linux')
apt install "$1" || echo "$p failed to install"
;;
'Darwin')
brew install "$1" || echo "$p failed to install"
;;
*) ;;
esac
echo "---------------------------------------------------------"
echo "Done "
echo "---------------------------------------------------------"
fi
done
}
create_dir() {
if [ ! -d "$1" ]; then
echo "Creating $1"
mkdir -p $1
fi
}
# Might as well ask for password up-front, right?
echo "Starting install script, please grant me sudo access..."
sudo -v
# Keep-alive: update existing sudo time stamp if set, otherwise do nothing.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
if [ "$(uname)" == "Darwin" ]; then
brew="/usr/local/bin/brew"
if [ -f "$brew" ]; then
echo "Homebrew is installed, nothing to do here"
else
echo "Homebrew is not installed, installing now"
echo "This may take a while"
echo "Homebrew requires osx command lines tools, please download xcode first"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi
fi
install_missing_packages || echo "failed to install missing packages"
# Clone my dotfiles repo into ~/.dotfiles/ if needed
echo "---------------------------------------------------------"
echo "dotfiles"
echo "---------------------------------------------------------"
export DOTFILES="$HOME/.dotfiles"
if [ -f "$DOTFILES" ]; then
echo "Dotfiles have already been cloned into the home dir"
else
echo "Cloning dotfiles"
git clone https://github.com/akinsho/dotfiles.git ~/.dotfiles
fi
cd "$DOTFILES" || "Didn't cd into dotfiles this will be bad :("
git submodule update --init --recursive
cd "$HOME" || exit
echo "---------------------------------------------------------"
echo "You'll need to log out for this to take effect"
echo "---------------------------------------------------------"
if [ "$(uname)" == "Darwin" ]; then
echo "---------------------------------------------------------"
echo "running macos defaults"
echo "this may take a while.. as well"
echo "---------------------------------------------------------"
source "$DOTFILES/configs/macos/install.sh"
echo "Installing brew bundle"
brew tap Homebrew/bundle
brew bundle --global
echo "Installing Homebrew apps from Brewfile"
fi
if [ ! -d "$HOME/.tmux/plugins/tpm" ]; then
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
# Install n node version manager program
curl -L https://git.io/n-install | bash
# Install rust
curl https://sh.rustup.rs -sSf | sh
# These are handled by homebrew on macos
if [ "$(uname)" == "Linux" ]
if exists cargo; then
cargo install stylua
cargo install git-delta
cargo install topgrade
# cargo install cargo-update # requires libopenssl-dev on ubuntu
# install ripgrep via cargo in case it failed via apt or brew
if ! exists rg; then
cargo install ripgrep
fi
fi
fi
# TODO install
# * lazygit for linux
# TODO pip3 dependencies
# * pip3 install neovim --upgrade
# * pip3 install --user neovim-remote
# Install fzf
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
echo "---------------------------------------------------------"
echo "Changing to zsh"
echo "---------------------------------------------------------"
chsh -s "$(which zsh)"
$DOTFILES/install
echo 'done'
echo "---------------------------------------------------------"
echo "All done!"
echo "Cheers"
echo "---------------------------------------------------------"
exit 0