-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathinstall.sh
executable file
·220 lines (190 loc) · 7.94 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/bash
# Formatting
normal=$(tput sgr0)
bold=$(tput bold)
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
grey=$(tput setaf 8)
# Command line arguments
vb=$1
# Directories
CONFIG_DIR=$HOME/.config
DOWNLOAD_DIR=$HOME/Downloads
# Header
printf "${grey}%s${normal}\n${bold}${green}%s${normal}\n${bold}${yellow}%s${normal}\n${yellow}%s${normal}\n${grey}%s${normal}\n\n" "
███████╗██╗ ██╗███████╗██████╗ ███████╗ ██████╗ ██████╗ ███████╗███████╗████████╗
██╔════╝██║ ██║██╔════╝██╔══██╗██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔════╝╚══██╔══╝
█████╗ ██║ ██║█████╗ ██████╔╝█████╗ ██║ ██║██████╔╝█████╗ ███████╗ ██║
██╔══╝ ╚██╗ ██╔╝██╔══╝ ██╔══██╗██╔══╝ ██║ ██║██╔══██╗██╔══╝ ╚════██║ ██║
███████╗ ╚████╔╝ ███████╗██║ ██║██║ ╚██████╔╝██║ ██║███████╗███████║ ██║
╚══════╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝
" \
"EVERFOREST CONFIGS FOR ARCH LINUX Version 2.0" \
"Author: Arfan Zubi" \
"Theme: Sainnhe Park" \
"License: 2023 GNU General Public License"
# Installation prompt
function main() {
while true; do
echo -e "${bold}${red}===> This installer will delete ALL files in your ~/.config directory.${normal}"
read -r -p "${yellow}Do you want to proceed? [y/N] ${normal}" yn
case $yn in
[Yy]*)
pre_install_checks
remove_git_directory
copy_config_files
copy_others
set_wallpaper
install_shell_tools
remove_install_file
echo "${bold}${green}Installation succeeded! Exiting...${normal}"
exit 0
;;
[Nn]* | "")
echo "${bold}${red}Aborting installation...${normal}"
exit 1
;;
*) echo "Please enter [y]es or [n]o!" ;;
esac
done
}
# Checking if ~/.config already exists and wipe it if it does
function pre_install_checks() {
if [[ -d "$CONFIG_DIR" ]]; then
echo "${yellow}$CONFIG_DIR does already exist, deleting all files...${normal}"
rm -rfv "$CONFIG_DIR"
else
echo "${yellow}Creating new config directory ($CONFIG_DIR)${normal}"
fi
# Creating new empty ~/.config
echo "${yellow}Creating new $CONFIG_DIR directory...${normal}"
mkdir -p "$CONFIG_DIR" || {
echo "${bold}${red}Failed creating ${CONFIG_DIR}, exiting...${normal}"
exit 1
}
echo "${yellow}Done!${normal}"
# Refreshing XDG user directories
echo "${yellow}Creating XDG user directories...${normal}"
xdg-user-dirs-update || {
echo "${bold}${red}Failed creating XDG user directories, exiting...${normal}"
exit 1
}
echo "${yellow}Done!${normal}"
}
# Removing .git directory so it won't get copied unnecessary
function remove_git_directory() {
if [[ -d $DOWNLOAD_DIR/dotfiles/.git ]]; then
echo "${yellow}Removing .git directory...${normal}"
rm -Rf "$DOWNLOAD_DIR/dotfiles/.git" || {
echo "${bold}${red}Failed removing .git directory, exiting...${normal}"
exit 1
}
echo "${yellow}Done!${normal}"
else
echo "${bold}${red}Make sure you cloned (https://github.com/3rfaan/dotfiles.git) into your ~/Downloads folder!${normal}"
exit 1
fi
}
# Copying dotfiles from Downloads folder to ~/.config
function copy_config_files() {
if [[ -d $DOWNLOAD_DIR/dotfiles ]]; then
echo "${yellow}Copying files from ${DOWNLOAD_DIR} to ${CONFIG_DIR}...${normal}"
cp -Rfv "$DOWNLOAD_DIR/dotfiles/." "$CONFIG_DIR" || {
echo "${bold}${red}Failed copying files from ${DOWNLOAD_DIR} to ${CONFIG_DIR}, exiting...${normal}"
exit 1
}
echo "${yellow}Done!${normal}"
else
echo "${bold}${red}Make sure you cloned (https://github.com/3rfaan/dotfiles.git) into your ~/Downloads folder!${normal}"
exit 1
fi
}
# Copying files which target destinations are not in ~/.config
function copy_others() {
if [[ -d $DOWNLOAD_DIR/dotfiles ]]; then
echo "${yellow}Copying files to other directories${normal}"
# If user provided command line argument ("utm" or "vbox") then copy X11 files to xorg.conf.d else don't copy anything to xorg.conf.d
if [ "$vb" == "utm" ]; then
sudo cp -Rfv "$DOWNLOAD_DIR/dotfiles/Xorg/UTM/." "/etc/X11/xorg.conf.d"
elif [ "$vb" == "vbox" ]; then
sudo cp -Rfv "$DOWNLOAD_DIR/dotfiles/Xorg/VBox/." "/etc/X11/xorg.conf.d"
fi
# If no argument was provided delete Xorg folder from ~/.config
if [ -z "$vb" ] && [ -d "$CONFIG_DIR/Xorg" ]; then
sudo rm -Rfv "$CONFIG_DIR/Xorg"
fi
if [[ ! -d "$HOME/.local/share/rofi" ]]; then
mkdir -p "$HOME/.local/share/rofi/themes"
cp -Rfv "$DOWNLOAD_DIR/dotfiles/rofi/squared-everforest.rasi" "$HOME/.local/share/rofi/themes/squared-everforest.rasi"
fi
cp -Rfv "$DOWNLOAD_DIR/dotfiles/Xorg/.xinitrc" "$HOME/.xinitrc"
cp -Rfv "$DOWNLOAD_DIR/dotfiles/zsh/.zshrc" "$HOME/.zshrc"
echo "${yellow}Done!${normal}"
else
echo "${bold}${red}Make sure you cloned (https://github.com/3rfaan/dotfiles.git) into your ~/Downloads folder!${normal}"
exit 1
fi
}
# Copying wallpaper to Downloads folder
function set_wallpaper() {
if [[ -d $DOWNLOAD_DIR/dotfiles ]]; then
echo "${yellow}Setting wallpaper${normal}"
cp -Rfv "$DOWNLOAD_DIR/dotfiles/flowers.png" "$DOWNLOAD_DIR/flowers.png"
echo "${yellow}Done!${normal}"
# Changing directory to ~/.config
cd "$CONFIG_DIR" || exit 1
echo "${yellow}Changed directory to $(pwd)${normal}"
echo "${yellow}Removing some unnecessary files...${normal}"
rm -rfv asus Xorg urxvt lf i3/i3status screenshot-*.png nvim/init.vim nvim/coc-settings.json install.sh zsh || {
echo "${bold}${red}Failed removing directories not needed for the configuration, exiting..."
exit 1
}
echo "${yellow}Done!${normal}"
else
echo "${bold}${red}Make sure you cloned (https://github.com/3rfaan/dotfiles.git) into your ~/Downloads folder!${normal}"
exit 1
fi
}
function install_shell_tools() {
if [[ -d $DOWNLOAD_DIR/dotfiles ]]; then
echo "${yellow}Installing shell tools${normal}"
# Packer
if [[ ! -d $HOME/.local/share/nvim/site/pack/packer ]]; then
git clone --depth 1 https://github.com/wbthomason/packer.nvim "$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim"
else
echo "${green}Packer is already installed${normal}"
fi
# ZSH auto suggestions
if [[ ! -d $HOME/.zsh/zsh-autosuggestions ]]; then
git clone https://github.com/zsh-users/zsh-autosuggestions "$HOME/.zsh/zsh-autosuggestions"
else
echo "${green}ZSH auto suggestions is already installed${normal}"
fi
# ZSH syntax highlighting
if [[ ! -d $HOME/.zsh/zsh-syntax-highlighting ]]; then
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$HOME/.zsh/zsh-syntax-highlighting"
else
echo "${green}ZSH syntax highlighting is already installed${normal}"
fi
# Icons for ranger
if [[ ! -d $CONFIG_DIR/ranger/plugins/ranger_devicons ]]; then
git clone https://github.com/alexanderjeurissen/ranger_devicons "$CONFIG_DIR/ranger/plugins/ranger_devicons"
else
echo "${green}Ranger devicons is already installed${normal}"
fi
else
echo "${bold}${red}Make sure you cloned (https://github.com/3rfaan/dotfiles.git) into your ~/Downloads folder!${normal}"
exit 1
fi
}
# Removing install files after moving them to .config
function remove_install_file() {
if [[ -d $DOWNLOAD_DIR/dotfiles ]]; then
echo "${yellow}Removing installation files...${normal}"
rm -rf "$DOWNLOAD_DIR/dotfiles"
echo "${yellow}Done removing installation files${normal}"
fi
}
main "$@"
exit