-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·131 lines (111 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
130
131
#!/bin/bash
install_neovim_centos() {
# Add EPEL repository for Neovim
sudo yum install -y epel-release
# Install Neovim
sudo yum install -y neovim
}
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "macOS detected"
# Check if Homebrew is installed
if ! command -v brew &>/dev/null; then
echo "Homebrew not found. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
echo "Homebrew is already installed"
fi
# Check and install Neovim, ripgrep, and Node.js if not already installed
packages=("neovim" "ripgrep" "node")
for package in "${packages[@]}"; do
if ! brew list $package &>/dev/null; then
echo "Installing $package..."
brew install $package
else
echo "$package is already installed"
fi
done
elif [[ -f /etc/centos-release ]]; then
echo "CentOS detected"
# Check and install Neovim, ripgrep, and Node.js if not already installed
if ! command -v nvim &>/dev/null; then
echo "Installing Neovim..."
install_neovim_centos
else
echo "Neovim is already installed"
fi
if ! command -v rg &>/dev/null; then
echo "Installing ripgrep..."
sudo yum install -y ripgrep
else
echo "ripgrep is already installed"
fi
if ! command -v node &>/dev/null; then
echo "Installing Node.js..."
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum install -y nodejs
else
echo "Node.js is already installed"
fi
else
echo "This script supports macOS and CentOS only"
exit 1
fi
backup_and_install_lazyvim() {
echo "Setting up Neovim..."
# Backup existing Neovim config and related directories
dirs_to_backup=(
"$HOME/.config/nvim"
"$HOME/.local/share/nvim"
"$HOME/.local/state/nvim"
"$HOME/.cache/nvim"
)
for dir in "${dirs_to_backup[@]}"; do
if [ -d "$dir" ]; then
backup_dir="${dir}.bak"
# Remove the existing backup directory if it exists
if [ -d "$backup_dir" ]; then
echo "Removing existing backup directory $backup_dir"
rm -rf "$backup_dir"
fi
echo "Backing up $dir to $backup_dir"
mv "$dir" "$backup_dir"
fi
done
# Create new Neovim config directory and copy LazyVim config
nvim_config_dir="$HOME/.config/nvim"
echo "Copying LazyVim config to $nvim_config_dir"
mkdir -p "$nvim_config_dir"
cp -R ./lazyvim/* "$nvim_config_dir/"
cp ./vscode/vscode_init.vim "$nvim_config_dir/"
echo "LazyVim config copied successfully"
echo "Neovim setup complete."
}
setup_tmux_conf() {
echo "Setting up Tmux configuration..."
cp ./.tmux.conf ~/.tmux.conf
echo "Tmux configuration file copied to home directory"
# Install tmux plugins manager
if [ ! -d ~/.tmux/plugins/tpm ]; then
echo "Installing Tmux Plugin Manager..."
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
else
echo "Tmux Plugin Manager is already installed"
fi
# Source the tmux configuration
if command -v tmux &>/dev/null; then
echo "Sourcing Tmux configuration..."
tmux source ~/.tmux.conf
else
echo "Tmux is not installed. Please install Tmux to use the configuration."
fi
echo "Tmux setup complete."
echo "Remember to install all plugins through TPM by pressing Ctrl+A, Shift+I in a Tmux session."
}
# Main script execution
backup_and_install_lazyvim
setup_tmux_conf
echo "Enjoy your new development environment!"
# TODO:
# 1. ".zshrc" template with pre-installed plugins
# 2. lazygit
# 3. use homebrew for linux as well