-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·131 lines (120 loc) · 4.26 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
# Define colors for output
GREEN="\033[1;32m"
RED="\033[1;31m"
BLUE="\033[1;34m"
NC="\033[0m" # No color
# Print functions
print_step() {
echo -e "${BLUE}==> $1${NC}"
}
print_success() {
echo -e "${GREEN}[✔] $1${NC}"
}
print_error() {
echo -e "${RED}[✘] $1${NC}"
exit 1
}
# Install Zsh
install_zsh() {
if command -v zsh &> /dev/null; then
print_success "Zsh is already installed"
if [[ "$SHELL" != "$(which zsh)" ]]; then
print_step "Setting Zsh as the default shell..."
chsh -s "$(which zsh)"
print_success "Zsh is now the default shell. Please log out and back in for changes to take effect."
else
print_success "Zsh is already the default shell"
fi
else
print_step "Installing Zsh..."
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command -v apt &> /dev/null; then
sudo apt update
sudo apt install -y zsh
elif command -v yum &> /dev/null; then
sudo yum install -y zsh
else
print_error "Unsupported Linux distribution. Please install Zsh manually."
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &> /dev/null; then
brew install zsh
else
print_error "Homebrew is required to install Zsh on macOS. Please install it and rerun this script."
fi
else
print_error "Unsupported OS. Please install Zsh manually."
fi
chsh -s "$(which zsh)"
print_success "Zsh installed and set as the default shell. Please log out and back in for changes to take effect."
fi
}
# Install Vim
install_vim() {
if command -v vim &> /dev/null; then
print_success "Vim is already installed"
else
print_step "Installing Vim..."
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command -v apt &> /dev/null; then
sudo apt update
sudo apt install -y vim
elif command -v yum &> /dev/null; then
sudo yum install -y vim
else
print_error "Unsupported Linux distribution. Please install Vim manually."
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &> /dev/null; then
brew install vim
else
print_error "Homebrew is required to install Vim on macOS. Please install it and rerun this script."
fi
else
print_error "Unsupported OS. Please install Vim manually."
fi
fi
}
# Install Tmux
install_tmux() {
if command -v tmux &> /dev/null; then
print_success "Tmux is already installed"
else
print_step "Installing Tmux..."
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command -v apt &> /dev/null; then
sudo apt update
sudo apt install -y tmux
elif command -v yum &> /dev/null; then
sudo yum install -y tmux
else
print_error "Unsupported Linux distribution. Please install Tmux manually."
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &> /dev/null; then
brew install tmux
else
print_error "Homebrew is required to install Tmux on macOS. Please install it and rerun this script."
fi
else
print_error "Unsupported OS. Please install Tmux manually."
fi
fi
}
# Create symbolic links for configuration files
create_symlinks() {
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
ln -sf "$SCRIPT_DIR/.zshrc" ~/.zshrc || print_error "Failed to create symlink for .zshrc"
ln -sf "$SCRIPT_DIR/.p10k.zsh" ~/.p10k.zsh || print_error "Failed to create symlink for .p10k.zsh"
ln -sf "$SCRIPT_DIR/vimrc" ~/.vimrc || print_error "Failed to create symlink for .vimrc"
print_success "Symbolic links created successfully"
}
# Main script
print_step "Starting dotfiles setup..."
install_zsh
install_vim
install_tmux
create_symlinks
print_step "Setup completed!"
echo -e "${BLUE}Please restart your terminal or log out and back in to apply the changes.${NC}"