-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzsh_arch.sh
93 lines (73 loc) · 2.75 KB
/
zsh_arch.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
#!/bin/bash
echo "Setting up Zsh and Oh My Zsh..."
# Install Zsh using pacman
if ! sudo pacman -S zsh curl git; then
echo "Error: Zsh installation failed."
exit 1
fi
echo "Zsh installed."
# Install Oh My Zsh using installation command from GitHub
if ! sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"; then
echo "Error: Oh My Zsh installation failed."
exit 1
fi
echo "Oh My Zsh installed."
# Change default shell to Zsh for the current user
if ! chsh -s $(which zsh); then
echo "Error: Changing default shell to Zsh failed."
exit 1
fi
echo "Changed default shell to Zsh."
# Clone zsh-autosuggestions plugin from GitHub repository
if ! git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions; then
echo "Error: Cloning zsh-autosuggestions plugin failed."
exit 1
fi
# Clone zsh-syntax-highlighting plugin from GitHub repository
if ! git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting; then
echo "Error: Cloning zsh-syntax-highlighting plugin failed."
exit 1
fi
echo "Cloned zsh-autosuggestions and zsh-syntax-highlighting plugins."
# Modify the ~/.zshrc file to include zsh-autosuggestions and zsh-syntax-highlighting plugins
if ! sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/' ~/.zshrc; then
echo "Error: Modifying ~/.zshrc failed."
exit 1
fi
# Update the Zsh configuration file
if ! source ~/.zshrc; then
echo "Error: Updating Zsh configuration failed."
exit 1
fi
echo "Updated Zsh configuration."
# Install Nerd Font (Meslo) using yay
if ! yay -S ttf-meslo-nerd-font-powerlevel10k; then
echo "Error: Nerd Font installation failed."
exit 1
fi
echo "Installed Nerd Font."
# Install Powerlevel10k theme for Zsh using git
if ! git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k; then
echo "Error: Installing Powerlevel10k theme failed."
exit 1
fi
echo "Installed Powerlevel10k theme."
# Ask the user if they want to add aliases
read -p "Do you want to add aliases? (y/N): " add_aliases
# Check the user's response
if [ "$add_aliases" == "y" ]; then
# Loop to add aliases until the user chooses to stop
while true; do
read -p "Enter an alias (or press Enter to exit): " new_alias
if [ -z "$new_alias" ]; then
break
fi
echo "alias $new_alias" >> ~/.zshrc
if ! source ~/.zshrc; then
echo "Error: Adding alias failed."
exit 1
fi
echo "Added alias: $new_alias"
done
fi
echo "Everything has been set up successfully. You can restart the terminal to see the changes."