This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
install
executable file
·137 lines (117 loc) · 5 KB
/
install
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
#!/usr/bin/env bash
## Author : Zim Muller
## Github : @zim0369
## Reddit : @zim0369
## kitty installer script
##
## ANSI Colors (FG & BG)
RED="$(printf '\033[31m')" GREEN="$(printf '\033[32m')" ORANGE="$(printf '\033[33m')" BLUE="$(printf '\033[34m')"
MAGENTA="$(printf '\033[35m')" CYAN="$(printf '\033[36m')" WHITE="$(printf '\033[37m')" BLACK="$(printf '\033[30m')"
REDBG="$(printf '\033[41m')" GREENBG="$(printf '\033[42m')" ORANGEBG="$(printf '\033[43m')" BLUEBG="$(printf '\033[44m')"
MAGENTABG="$(printf '\033[45m')" CYANBG="$(printf '\033[46m')" WHITEBG="$(printf '\033[47m')" BLACKBG="$(printf '\033[40m')"
DEFAULT_FG="$(printf '\033[39m')" DEFAULT_BG="$(printf '\033[49m')"
## Directories
DIR="$(pwd)"
KITTY_DIR="$HOME/.config/kitty"
## Banner
banner () {
clear
printf '%s\n' "
${ORANGE}☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴
${CYAN}██▓▒░⡷⠂${RED} 𝓟𝓻𝓮𝓽𝓽𝔂 𝓚𝓲𝓽𝓽𝔂 ${BLUE}🐈 ${CYAN}⠐⢾░▒▓██
${ORANGE}☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴☴
"
}
## Script Termination
exit_on_signal_SIGINT () {
{ printf "%s\n" " ${CYAN}[${RED}✗${CYAN}] ${BLUE}Script interrupted" 2>&1; reload_settings; reset_color; }
exit 0
}
exit_on_signal_SIGTERM () {
{ printf "%s\n" " ${CYAN}[${RED}*${CYAN}] ${BLUE}Script terminated" 2>&1; reload_settings; reset_color; }
exit 0
}
trap exit_on_signal_SIGINT SIGINT
trap exit_on_signal_SIGTERM SIGTERM
## Reset terminal colors
reset_color() {
tput sgr0 # reset attributes
tput op # reset color
return
}
## Prerequisite
prerequisite() {
dependencies=(kitty fzf git sed grep find wget)
for dependency in "${dependencies[@]}"; do
type -p "$dependency" &>/dev/null || {
banner
printf '%s\n' " ${BLUE}[${RED}!${BLUE}] ${RED}ERROR: Could not find ${MAGENTA}'${dependency}'${RED}, is it installed?" >&2;
{ reset_color; exit 1; }
}
done
}
## Check for previous installation
check_prev () {
banner
if [[ (-L /usr/local/bin/pkitty) || (-f /usr/local/bin/pkitty) ]]; then
printf '%s\n' " ${BLUE}[${RED}!${BLUE}] ${MAGENTA}pretty-kitty ${GREEN}is already installed.";
{ read -r -n 1 -p " ${BLUE}[${RED}?${BLUE}] ${ORANGE}Do you wish to update? (y/n): ${GREEN}"; printf "\n"; }
if [[ "$REPLY" =~ ^[y/Y]$ ]]; then
install_pkitty
else
printf '%s\n' " ${BLUE}[${RED}!${BLUE}] ${MAGENTA}Updated Cancelled";
{ reset_color; exit; }
fi
else
{ printf "\n"; install_pkitty; }
fi
}
## Install pretty-kitty
install_pkitty () {
printf '%s\n' " ${BLUE}[${RED}*${BLUE}] ${ORANGE}Installing pretty-kitty..."
# Delete old files
if [[ (-L /usr/local/bin/pkitty) && (-d /usr/local/share/pretty-kitty) ]]; then
printf '%s\n' " ${BLUE}[${RED}*${BLUE}] ${RED}Deleting files from previous installation...${BLUE}"
printf '%s\n' " "
sudo rm -r /usr/local/bin/pkitty /usr/local/share/pretty-kitty /usr/local/share/fonts/pretty-kitty
fi
# pretty-kitty config dir
if [[ ! -d $KITTY_DIR ]]; then
mkdir "$KITTY_DIR"
fi
if ! [ -s "${KITTY_DIR}/kitty.conf" ]; then
printf '%s\n' " ${BLUE}[${RED}!${BLUE}] ${RED}Cannot find kitty configuration: '${KITTY_DIR}/kitty.conf'${BLUE}"
printf '%s\n' " ${BLUE}[${RED}!${BLUE}] ${RED}Creating one for you...${BLUE}"
cp "$DIR/kitty.conf" "$KITTY_DIR"
printf '%s\n' " ${BLUE}[${RED}!${BLUE}] ${RED}Please restart kitty after install...";
fi
if [ ! -f "${KITTY_DIR}/colors.conf" ]; then
touch "${KITTY_DIR}/colors.conf"
fi
if ! grep --quiet 'colors\.conf' "${KITTY_DIR}/kitty.conf"; then
printf '%s\n' " ${BLUE}[${RED}*${BLUE}] ${RED}Adding pretty-kitty import to kitty config..."
printf '%s\n' "include ${KITTY_DIR}/colors.conf" >> "${KITTY_DIR}/kitty.conf"
printf '%s\n' " ${BLUE}[${RED}!${BLUE}] ${RED}Please restart kitty after install...";
fi
# Copying files
printf '%s\n' " ${BLUE}[${RED}*${BLUE}] ${ORANGE}Copying files to '/usr/local/share' directory...${BLUE}";
{ printf '%s\n' " "; sudo mkdir /usr/local/share/pretty-kitty; sudo mkdir -p /usr/local/share/fonts/pretty-kitty; }
{ sudo cp -r "$DIR/colors" "$DIR/uninstall" "$DIR/pkitty" "$DIR/kitty.conf" /usr/local/share/pretty-kitty/; sudo cp -r "$DIR/fonts/"* /usr/local/share/fonts/pretty-kitty/; }
sudo chmod +x /usr/local/share/pretty-kitty/pkitty /usr/local/share/pretty-kitty/uninstall;
sudo fc-cache; sudo ln -s /usr/local/share/pretty-kitty/pkitty /usr/local/bin/pkitty;
# Verify files
if [[ (-L /usr/local/bin/pkitty) && (-d /usr/local/share/pretty-kitty) ]]; then
printf '%s\n' " ${BLUE}[${RED}*${BLUE}] ${GREEN}Successfully Installed.";
printf '%s\n' " ${BLUE}[${RED}*${BLUE}] ${GREEN}Now You Can Run This Program By Just typing ${MAGENTA}pkitty${GREEN}.";
{ reset_color; exit 0; }
else
{ printf '%s\n' " ${BLUE}[${RED}!${BLUE}] ${RED}Error Occured."; reset_color; exit 1; }
fi
}
## Main
main () {
prerequisite
check_prev
banner
}
main