-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·188 lines (169 loc) · 4.54 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/bin/bash
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Detect the OS using uname -s
OS=$(uname -s)
# Function to install Zsh
install_zsh() {
echo "Installing Zsh..."
if ! command_exists zsh; then
if [ "$OS" = "Linux" ]; then
sudo apt-get update && sudo apt-get install -y zsh
elif [ "$OS" = "Darwin" ]; then
brew install zsh
fi
else
echo "Zsh is already installed"
fi
}
# Function to install Oh My Zsh
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)"
else
echo "Oh My Zsh is already installed"
fi
}
# Function to install Conda
install_conda() {
echo "Installing Conda..."
if ! command_exists conda; then
if [ "$OS" = "Linux" ]; then
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
elif [ "$OS" = "Darwin" ]; then
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O ~/miniconda.sh
fi
bash ~/miniconda.sh -b -p $HOME/miniconda
rm ~/miniconda.sh
else
echo "Conda is already installed"
fi
}
# Function to install Git
install_git() {
echo "Installing Git..."
if ! command_exists git; then
if [ "$OS" = "Linux" ]; then
sudo apt-get update && sudo apt-get install -y git
elif [ "$OS" = "Darwin" ]; then
brew install git
fi
else
echo "Git is already installed"
fi
}
# Function to install NvChad
install_neovim_chad() {
echo "Installing NvChad..."
if ! [ -d "$HOME/nerd-fonts" ]; then
original_dir=$PWD
rm -r ~/nerd-fonts || true
git clone https://github.com/ryanoasis/nerd-fonts ~/nerd-fonts --depth 1
cd ~/nerd-fonts
./install.sh -q JetBrainsMono || true
cd $original_dir
else
echo "Nerd Fonts is already installed"
fi
if ! [ -d "$HOME/.config/nvim" ]; then
rm -r ~/.config/nvim.backup || true
mkdir -p ~/.config/nvim.backup/
mkdir -p ~/.config/nvim/
mv ~/.config/nvim ~/.config/nvim.backup
git clone https://github.com/NvChad/starter ~/.config/nvim
else
echo "NvChad is already installed"
fi
}
# Function to install Neovim
install_neovim() {
echo "Installing Neovim..."
if ! command_exists nvim; then
if [ "$OS" = "Linux" ]; then
sudo snap install nvim --classic # using snap to get the latest version of neovim
elif [ "$OS" = "Darwin" ]; then
brew install neovim
fi
else
echo "Neovim is already installed"
fi
}
# Function to install Tmux
install_tmux() {
echo "Installing Tmux..."
if ! command_exists tmux; then
if [ "$OS" = "Linux" ]; then
sudo apt-get update && sudo apt-get install -y tmux
elif [ "$OS" = "Darwin" ]; then
brew install tmux
fi
else
echo "Tmux is already installed"
fi
}
install_brew() {
echo "Installing Homebrew..."
if ! command_exists brew; then
if [ "$OS" = "Darwin" ]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
else
echo "Homebrew is already installed"
fi
}
install_stow() {
echo "Installing Stow..."
if ! command_exists stow; then
if [ "$OS" = "Linux" ]; then
sudo apt-get update && sudo apt-get install -y stow
elif [ "$OS" = "Darwin" ]; then
brew install stow
fi
else
echo "Stow is already installed"
fi
}
set_symlinks() {
echo "Setting symlinks using stow from $(pwd)..."
if [ -f "$HOME/.zshrc" ]; then
mv $HOME/.zshrc $HOME/.zshrc.backup
fi
stow -v -R -t $HOME terminal
stow -v -R -t $HOME config
}
install_additional_deps () {
echo "Installing additional dependencies..."
if [ "$OS" = "Linux" ]; then
sudo apt-get update && sudo apt-get install -y gh tree snapd
sudo snap install tldr
elif [ "$OS" = "Darwin" ]; then
brew install gh tree tldr
fi
}
setup_conda() {
echo "Setting up Conda..."
if ! command_exists conda; then
$HOME/miniconda/bin/conda init zsh
else
conda init zsh
fi
}
main() {
install_brew
install_additional_deps
install_zsh
install_oh_my_zsh
install_conda
install_git
install_neovim
install_neovim_chad
install_tmux
install_stow
set_symlinks
setup_conda
echo "All requested dependencies are installed."
}
main