-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·614 lines (582 loc) · 19.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
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
#!/bin/bash
SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
have_real=$(type -p realpath)
[ "${have_real}" ] && SCRIPT_PATH="$(realpath "$SCRIPT_PATH")"
REPO_URL="https://github.com/doctorfree/kitty-control"
KCONF="${HOME}/.config/kitty"
KCDIR="${KCONF}/kitty-control"
FONT_URL="https://raw.githubusercontent.com/wiki/doctorfree/workspaces-images"
export KCKITTEN="kc_read_config.py"
# Use './install --force' to overwrite any existing neofetch/fastfetch configs
force=
[ "$1" == "--force" ] && force=1
install_kitty() {
if [ "${darwin}" ]; then
KTAPP="/Applications/kitty.app"
LOCAL="${KTAPP}/Contents"
KBIN="${LOCAL}/MacOS"
KTINFO="${LOCAL}/Resources/kitty/terminfo/kitty.terminfo"
KXTERM="${LOCAL}/Resources/kitty/terminfo/78/xterm-kitty"
KSTERM="${LOCAL}/Resources/terminfo/78/xterm-kitty"
else
LOCAL="${HOME}/.local/kitty.app"
KBIN="${LOCAL}/bin"
KTINFO="${LOCAL}/lib/kitty/terminfo/kitty.terminfo"
KXTERM="${LOCAL}/lib/kitty/terminfo/x/xterm-kitty"
KSTERM="${LOCAL}/share/terminfo/x/xterm-kitty"
fi
printf "\n\tInstalling Kitty terminal emulator ..."
installer_url="https://sw.kovidgoyal.net/kitty/installer.sh"
if [ "${have_curl}" ]; then
curl --silent --location ${installer_url} >/tmp/kitty-$$.sh
[ $? -eq 0 ] || {
rm -f /tmp/kitty-$$.sh
curl --insecure --silent --location ${installer_url} >/tmp/kitty-$$.sh
cat /tmp/kitty-$$.sh | sed -e "s/curl -/curl -k/" >/tmp/k$$
cp /tmp/k$$ /tmp/kitty-$$.sh
rm -f /tmp/k$$
}
else
[ "${have_wget}" ] && wget --quiet -O /tmp/kitty-$$.sh ${installer_url}
fi
if [ -s /tmp/kitty-$$.sh ]; then
sh /tmp/kitty-$$.sh launch=n >/dev/null 2>&1
rm -f /tmp/kitty-$$.sh
# Create a symbolic link to add kitty to PATH
[ -d ~/.local/bin ] || mkdir -p ~/.local/bin
if [ -x ${KBIN}/kitty ]; then
[ -x ~/.local/bin/kitty ] || {
ln -s ${KBIN}/kitty ~/.local/bin/
}
else
printf "\nUnable to create Kitty link to ~/.local/bin/\n"
fi
if [ -x ${KBIN}/kitten ]; then
[ -x ~/.local/bin/kitten ] || {
ln -s ${KBIN}/kitten ~/.local/bin/
}
else
printf "\nUnable to create kitten link to ~/.local/bin/\n"
fi
# Link the kitty man pages somewhere it can be found by the man command
if [ "${darwin}" ]; then
LINMAN="/Applications/kitty.app/Contents/Resources/man"
else
LINMAN="${LOCAL}/share/man"
fi
[ -d ~/.local/share/man/man1 ] || mkdir -p ~/.local/share/man/man1
[ -f ~/.local/share/man/man1/kitty.1 ] || {
[ -d ${HOME}/.local/share/man/man1 ] || {
mkdir -p ${HOME}/.local/share/man/man1
}
[ -f "${LINMAN}/man1/kitty.1" ] && {
ln -s "${LINMAN}/man1/kitty.1" ~/.local/share/man/man1/
}
}
[ -d ~/.local/share/man/man5 ] || mkdir -p ~/.local/share/man/man5
[ -f ~/.local/share/man/man5/kitty.conf.5 ] || {
[ -d ${HOME}/.local/share/man/man5 ] || {
mkdir -p ${HOME}/.local/share/man/man5
}
[ -f "${LINMAN}/man5/kitty.conf.5" ] && {
ln -s "${LINMAN}/man5/kitty.conf.5" ~/.local/share/man/man5/
}
}
# Place the kitty.desktop file somewhere it can be found by the OS
[ -d ~/.local/share/applications ] || mkdir -p ~/.local/share/applications
[ -f "${LOCAL}/share/applications/kitty.desktop" ] && {
[ -f ~/.local/share/applications/kitty.desktop ] || {
cp ${LOCAL}/share/applications/kitty.desktop \
~/.local/share/applications/
}
}
# If you want to open text files and images in kitty via your file manager
# also add the kitty-open.desktop file
[ -f "${LOCAL}/share/applications/kitty-open.desktop" ] && {
[ -f ~/.local/share/applications/kitty-open.desktop ] || {
cp ${LOCAL}/share/applications/kitty-open.desktop \
~/.local/share/applications/
}
}
# Update the paths to the kitty and its icon in the kitty.desktop file(s)
for desktop in "${HOME}"/.local/share/applications/kitty*.desktop
do
[ "${desktop}" == "${HOME}/.local/share/applications/kitty*.desktop" ] && continue
[ -f ${LOCAL}/share/icons/hicolor/256x256/apps/kitty.png ] && {
sed -i "s|Icon=kitty|Icon=${LOCAL}/share/icons/hicolor/256x256/apps/kitty.png|g" "${desktop}"
}
[ -x ${LOCAL}/bin/kitty ] && {
sed -i "s|Exec=kitty|Exec=${LOCAL}/bin/kitty|g" "${desktop}"
}
done
printf " done!\n"
else
printf "\n${BOLD}ERROR:${NORM} Download of kitty installation script failed"
printf "\nSee https://sw.kovidgoyal.net/kitty/binary/#manually-installing"
printf "\nto manually install the kitty terminal emulator\n"
fi
# Install the Kitty terminfo entry
KITERM="${HOME}/.terminfo/x/xterm-kitty"
MATERM="${HOME}/.terminfo/78/xterm-kitty"
[ -f "${KITERM}" ] || [ -f "${MATERM}" ] || {
[ -d ${HOME}/.terminfo ] || mkdir -p ${HOME}/.terminfo
[ -d ${HOME}/.terminfo/x ] || mkdir -p ${HOME}/.terminfo/x
[ -d ${HOME}/.terminfo/78 ] || mkdir -p ${HOME}/.terminfo/78
[ "${have_tic}" ] && {
[ -f "${KTINFO}" ] && {
tic -x -o ${HOME}/.terminfo "${KTINFO}" >/dev/null 2>&1
}
}
[ -f "${KITERM}" ] || [ -f "${MATERM}" ] || {
if [ -f "${KXTERM}" ]; then
cp "${KXTERM}" "${KITERM}"
else
if [ -f "${KSTERM}" ]; then
cp "${KSTERM}" "${KITERM}"
else
printf "\nUnable to create Kitty terminfo entry ${KITERM}\n"
fi
fi
}
}
[ "${darwin}" ] && {
have_xattr=$(type -p xattr)
[ "${have_xattr}" ] && {
xattr -cr "${KTAPP}"
[ $? -eq 0 ] || {
printf "\nWARNING: attribute modification for ${KTAPP} failed"
printf "\nPermission to modify this application may need to be granted"
printf "\nSee 'Privacy & Security' -> 'App Management' in 'Settings'\n"
}
}
}
}
fixup_conf_shell() {
SFILE="$1"
[ -f "${SFILE}" ] || return
if [ -n "$($SHELL -c 'echo $ZSH_VERSION')" ]; then
cat ${SFILE} | sed -e "s/^#map /map /" > /tmp/kc$$
cp /tmp/kc$$ ${SFILE}
rm -f /tmp/kc$$
elif [ -n "$($SHELL -c 'echo $BASH_VERSION')" ]; then
cat ${SFILE} | \
sed -e "s/^#map /map /" -e "s/tab zsh/tab bash/" > /tmp/kc$$
cp /tmp/kc$$ ${SFILE}
rm -f /tmp/kc$$
fi
}
install_kconf() {
[ -d ${KCONF} ] || mkdir -p ${KCONF}
for py in "${SCRIPT_PATH}"/config/*.py
do
[ "${py}" == "${SCRIPT_PATH}/config/*.py" ] && continue
cp "${py}" ${KCONF}
done
cp "${SCRIPT_PATH}"/config/kitty.conf ${KCONF}
fixup_conf_shell "${KCONF}/kitty.conf"
}
install_kicon() {
KICON="$1"
if [ "${darwin}" ]; then
[ -f "${SCRIPT_PATH}"/icons/kitty.app.icns ] && {
cp "${SCRIPT_PATH}"/icons/kitty.app.icns "${KICON}"
}
else
[ -f "${SCRIPT_PATH}"/icons/kitty-128.png ] && {
cp "${SCRIPT_PATH}"/icons/kitty-128.png "${KICON}"
}
fi
}
install_config() {
# We use $HOME/.config/kitty/kitty-control for kitty-control
DEST="$1"
[ -d "${DEST}" ] || mkdir -p "${DEST}"
[ -d "${DEST}"/kitty-control ] || mkdir -p "${DEST}"/kitty-control
find "${DEST}" -name ${KCKITTEN} -print0 | xargs -0 rm -f
cp "${SCRIPT_PATH}"/kitten/${KCKITTEN} "${DEST}"
chmod 644 "${DEST}"/${KCKITTEN}
[ -f "${DEST}"/diff.conf ] || {
cp "${SCRIPT_PATH}"/config/diff.conf "${DEST}"/diff.conf
chmod 644 "${DEST}"/diff.conf
}
if [ -d "${DEST}"/kitty-control ]; then
for ex in "${SCRIPT_PATH}"/config/*
do
[ "${ex}" == "${SCRIPT_PATH}/config/*" ] && continue
b=$(basename "${ex}")
if [ -d "${ex}" ]; then
if [ -d "${DEST}"/kitty-control/$b ]; then
cp "${ex}"/* "${DEST}"/kitty-control/$b
else
cp -a "${ex}" "${DEST}"/kitty-control/$b
fi
else
cp "${ex}" "${DEST}"/kitty-control/$b
fi
done
else
cp -a "${SCRIPT_PATH}"/config "${DEST}"/kitty-control
fi
# Fix the shell in kitty-control session files
[ -d "${DEST}"/kitty-control/sessions ] && {
find "${DEST}"/kitty-control/sessions -type f | while read sfile
do
grep zsh "${sfile}" > /dev/null && {
if [ -n "$($SHELL -c 'echo $BASH_VERSION')" ]; then
cat "${sfile}" | sed -e "s/ zsh/ bash/" > /tmp/kc$$
cp /tmp/kc$$ "${sfile}"
rm -f /tmp/kc$$
fi
}
done
if [ -d "${DEST}"/sessions ]; then
for sf in "${DEST}"/kitty-control/sessions/*
do
b=$(basename "${sf}")
[ -f "${DEST}"/sessions/$b ] || cp ${sf} "${DEST}"/sessions/$b
done
else
cp -a "${DEST}"/kitty-control/sessions "${DEST}"/sessions
fi
}
# Link to the new location of the kitten
[ -f "${DEST}"/${KCKITTEN} ] && {
export DEST
find "${DEST}" -name kitty.conf | while read kitty_conf
do
kcpath=$(dirname "${kitty_conf}")
[ -f "${kcpath}"/${KCKITTEN} ] || {
ln -s "${DEST}"/${KCKITTEN} ${kcpath}/${KCKITTEN}
}
[ "${kitty_conf}" == "${KCONF}/kitty.conf" ] || {
fixup_conf_shell "${kitty_conf}"
}
done
}
}
install_fonts() {
printf "\nInstalling JetBrains Mono Nerd Font\n"
if [ "${have_wget}" ]; then
wget --quiet -O /tmp/fonts.tar.gz ${FONT_URL}/fonts/JetBrainsMonoNerdFont.tar.gz
else
[ "${have_curl}" ] && {
curl --silent --location \
${FONT_URL}/fonts/JetBrainsMonoNerdFont.tar.gz >/tmp/fonts.tar.gz
}
fi
[ -f /tmp/fonts.tar.gz ] && {
[ -d ${usr_font_dir} ] || mkdir -p ${usr_font_dir}
tar xzf /tmp/fonts.tar.gz -C ${usr_font_dir}
rm -f /tmp/fonts.tar.gz
have_fc=$(type -p fc-cache)
[ "${have_fc}" ] && fc-cache -f
}
}
pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="$1${PATH:+":$PATH"}"
fi
}
pathadd "${HOME}/.local/bin"
pathadd "${HOME}/.fzf/bin"
export PATH
have_git=$(type -p git)
[ "${have_git}" ] || {
printf "\nERROR: cannot locate required git command"
printf "\nInstall git and re-run this install script\n\n"
exit 1
}
printf "\nInstalling kitty-control\n"
darwin=
icon_name=
icon_size="512"
fast_type="kitty-direct"
platform=$(uname -s)
if [ "${platform}" == "Darwin" ]; then
darwin=1
icon_name="apple-logo"
icon_size="384"
fast_type="kitty"
else
[ -f /etc/os-release ] && {
. /etc/os-release
icon_name="${ID}"
}
fi
[ "${icon_name}" ] || {
icon_size="256"
icon_name="kitty"
}
have_curl=$(type -p curl)
have_fzf=$(type -p fzf)
have_rich=$(type -p rich)
have_python=$(type -p python3)
have_tic=$(type -p tic)
have_wget=$(type -p wget)
have_kitty=$(type -p kitty)
[ "${have_kitty}" ] || install_kitty
[ -f "${KCONF}/kitty.conf" ] || install_kconf
if [ "${darwin}" ]; then
[ -f "${KCONF}/kitty.app.icns" ] || {
install_kicon "${KCONF}"/kitty.app.icns
rm /var/folders/*/*/*/com.apple.dock.iconcache
killall Dock
}
else
[ -f "${KCONF}"/kitty.app.png ] || install_kicon "${KCONF}"/kitty.app.png
fi
# If standalone install, clone the repository, run the install script, exit
[ -f "${SCRIPT_PATH}"/bin/kitty-control ] || {
printf "\nCloning kitty-control repository\n"
git clone ${REPO_URL} /tmp/kc$$ >/dev/null 2>&1
[ -x /tmp/kc$$/install ] || {
[ -f /tmp/kc$$/install ] || {
printf "\nERROR: installation failure, missing files.\n\n"
exit 1
}
chmod 755 /tmp/kc$$/install
}
/tmp/kc$$/install
rm -rf /tmp/kc$$
exit 0
}
# Copy kitty-control, kc_read_config.py, man pages
[ -d ${HOME}/.local/bin ] || mkdir -p ${HOME}/.local/bin
cp "${SCRIPT_PATH}"/bin/kitty-control ${HOME}/.local/bin/kitty-control
chmod 755 ${HOME}/.local/bin/kitty-control
# Fixup and copy nfetch script
[ -f "${SCRIPT_PATH}"/bin/nfetch ] && {
cat "${SCRIPT_PATH}"/bin/nfetch | \
sed -e "s/__SIZE__/${icon_size}/g" \
-e "s/__PLATFORM__/${icon_name}/" > ${HOME}/.local/bin/nfetch
chmod 755 ${HOME}/.local/bin/nfetch
rm -f ${HOME}/.local/bin/ffetch
ln -s ${HOME}/.local/bin/nfetch ${HOME}/.local/bin/ffetch
}
install_config "${HOME}/.config/kitty"
[ "${KITTY_CONFIG_DIRECTORY}" ] && {
[ "${KITTY_CONFIG_DIRECTORY}" == "${HOME}/.config/kitty" ] || {
install_config "${KITTY_CONFIG_DIRECTORY}"
if [ "${darwin}" ]; then
[ -f "${KITTY_CONFIG_DIRECTORY}/kitty.app.icns" ] || {
install_kicon "${KITTY_CONFIG_DIRECTORY}"/kitty.app.icns
}
else
[ -f "${KITTY_CONFIG_DIRECTORY}"/kitty.app.png ] || {
install_kicon "${KITTY_CONFIG_DIRECTORY}"/kitty.app.png
}
fi
}
}
[ -d ${HOME}/.local/share ] || mkdir -p ${HOME}/.local/share
[ -d ${HOME}/.local/share/man ] || mkdir -p ${HOME}/.local/share/man
[ -d ${HOME}/.local/share/man/man1 ] || mkdir -p ${HOME}/.local/share/man/man1
cp -p "${SCRIPT_PATH}"/man/man1/* ${HOME}/.local/share/man/man1
# Install Figlet Fonts used by kitty-control
FDEST="${HOME}/.local/share/figlet-fonts"
[ -d ${HOME}/.local/share ] || mkdir -p ${HOME}/.local/share
[ -d ${FDEST} ] || mkdir -p ${FDEST}
for ff in "${SCRIPT_PATH}"/figlet-fonts/*
do
[ "${ff}" == "${SCRIPT_PATH}/figlet-fonts/*" ] && continue
bn=$(basename "${ff}")
[ -f "${FDEST}/${bn}" ] && continue
cp "${ff}" ${FDEST}
chmod 644 "${FDEST}/${bn}"
done
chmod 755 ${FDEST}/*.sh
# Install fzf fuzzy finder
[ -f ${HOME}/.local/bin/fzf ] && {
mv ${HOME}/.local/bin/fzf ${HOME}/.local/bin/fzf-bak$$
}
[ "${have_fzf}" ] || {
printf "\nInstalling fzf fuzzy finder\n"
[ -d ${HOME}/.fzf ] && mv ${HOME}/.fzf ${HOME}/.fzf$$
git clone --depth 1 https://github.com/junegunn/fzf.git \
${HOME}/.fzf >/dev/null 2>&1
[ -f ${HOME}/.fzf/install ] && chmod 755 ${HOME}/.fzf/install
[ -x ${HOME}/.fzf/install ] && ${HOME}/.fzf/install --all >/dev/null 2>&1
}
if [ -f ${HOME}/.fzf/bin/fzf ]; then
ln -s ${HOME}/.fzf/bin/fzf ${HOME}/.local/bin/fzf
rm -f ${HOME}/.local/bin/fzf-bak$$
else
[ -f ${HOME}/.local/bin/fzf-bak$$ ] && {
mv ${HOME}/.local/bin/fzf-bak$$ ${HOME}/.local/bin/fzf
}
fi
# Install rich cli
[ "${have_rich}" ] || {
[ "${have_python}" ] && {
printf "\nInstalling rich-cli fancy output toolbox\n"
[ -f ${HOME}/.venv/bin/activate ] || {
python3 -m venv ${HOME}/.venv >/dev/null 2>&1
}
[ -f ${HOME}/.venv/bin/activate ] && source ${HOME}/.venv/bin/activate
[ -x ${HOME}/.venv/bin/python ] && {
${HOME}/.venv/bin/python -m pip install rich-cli >/dev/null 2>&1
[ -x ${HOME}/.venv/bin/rich ] && {
ln -s ${HOME}/.venv/bin/rich ${HOME}/.local/bin/rich
}
}
}
}
# Use a nicer Kitty icon
printf "\nInstalling nicer Kitty icons\n"
if [ "${darwin}" ]; then
APP="/Applications/kitty.app/Contents/Resources/kitty/logo"
icon="${APP}"/kitty.png
SUDO=
[ -w "${APP}" ] || SUDO="sudo"
[ -f "${SCRIPT_PATH}"/icons/kitty-256.png ] && {
if [ -f ${icon} ]; then
diff "${icon}" "${SCRIPT_PATH}"/icons/kitty-256.png >/dev/null || {
${SUDO} cp "${icon}" "${icon}.bak"
${SUDO} cp "${SCRIPT_PATH}"/icons/kitty-256.png "${icon}"
}
else
APPDIR=$(dirname "${icon}")
[ -d ${APPDIR} ] && ${SUDO} cp "${SCRIPT_PATH}"/icons/kitty-256.png "${icon}"
fi
}
icon="${APP}/kitty-128.png"
[ -f "${SCRIPT_PATH}"/icons/kitty-128.png ] && {
if [ -f ${icon} ]; then
diff "${icon}" "${SCRIPT_PATH}"/icons/kitty-128.png >/dev/null || {
${SUDO} cp "${icon}" "${icon}.bak"
${SUDO} cp "${SCRIPT_PATH}"/icons/kitty-128.png "${icon}"
}
else
APPDIR=$(dirname "${icon}")
[ -d ${APPDIR} ] && ${SUDO} cp "${SCRIPT_PATH}"/icons/kitty-128.png "${icon}"
fi
}
else
APP="${HOME}/.local/kitty.app"
for icon in ${APP}/lib/kitty/logo/kitty.png \
${APP}/share/icons/hicolor/256x256/apps/kitty.png
do
[ -f "${SCRIPT_PATH}"/icons/kitty-256.png ] && {
if [ -f ${icon} ]; then
diff "${icon}" "${SCRIPT_PATH}"/icons/kitty-256.png >/dev/null || {
cp "${icon}" "${icon}.bak"
cp "${SCRIPT_PATH}"/icons/kitty-256.png "${icon}"
}
else
APPDIR=$(dirname "${icon}")
[ -d ${APPDIR} ] && cp "${SCRIPT_PATH}"/icons/kitty-256.png "${icon}"
fi
}
done
icon="${APP}/lib/kitty/logo/kitty-128.png"
[ -f "${SCRIPT_PATH}"/icons/kitty-128.png ] && {
if [ -f ${icon} ]; then
diff "${icon}" "${SCRIPT_PATH}"/icons/kitty-128.png >/dev/null || {
cp "${icon}" "${icon}.bak"
cp "${SCRIPT_PATH}"/icons/kitty-128.png "${icon}"
}
else
APPDIR=$(dirname "${icon}")
[ -d ${APPDIR} ] && cp "${SCRIPT_PATH}"/icons/kitty-128.png "${icon}"
fi
}
fi
# Kitty session desktop file icon
ICON_DIR="${HOME}/.local/share/icons/hicolor/256x256/apps"
[ -d "${ICON_DIR}" ] || mkdir -p "${ICON_DIR}"
[ -f "${SCRIPT_PATH}"/icons/kitty-256.png ] && {
[ -f "${ICON_DIR}"/kitty.png ] || {
cp "${SCRIPT_PATH}"/icons/kitty-256.png "${ICON_DIR}"/kitty.png
}
}
# Kitty session desktop file
APP_DIR="${HOME}/.local/share/applications"
[ -d "${APP_DIR}" ] || mkdir -p "${APP_DIR}"
[ -f "${SCRIPT_PATH}"/kitty-session.desktop ] && {
[ -f "${APP_DIR}"/kitty-session.desktop ] || {
cp "${SCRIPT_PATH}"/kitty-session.desktop "${APP_DIR}"/kitty-session.desktop
}
}
# Kitty session startup file
SES_DIR="${HOME}/.config/kitty/sessions"
[ -d "${SES_DIR}" ] || mkdir -p "${SES_DIR}"
for start in startup startup-bash; do
[ -f "${SCRIPT_PATH}"/config/sessions/${start} ] && {
[ -f "${SES_DIR}"/${start} ] || {
cp "${SCRIPT_PATH}"/config/sessions/${start} "${SES_DIR}"/${start}
}
}
done
# Additional icons
ICON_DIR="${HOME}/.local/share/icons/hicolor/512x512/apps"
[ -d "${ICON_DIR}" ] || mkdir -p "${ICON_DIR}"
[ -f "${SCRIPT_PATH}"/icons/kitty-512.png ] && {
[ -f "${ICON_DIR}"/kitty.png ] || {
cp "${SCRIPT_PATH}"/icons/kitty-512.png "${ICON_DIR}"/kitty.png
}
}
for icon in alpine.png apple-logo.png arch.png centos.png debian.png \
fedora.png opensuse.png rocky.png tux.png ubuntu.png void.png
do
[ -f "${SCRIPT_PATH}"/icons/${icon} ] && {
cp "${SCRIPT_PATH}"/icons/${icon} "${ICON_DIR}"/${icon}
}
done
for size in "256" "384"
do
ICON_DIR="${HOME}/.local/share/icons/hicolor/${size}x${size}/apps"
[ -d "${ICON_DIR}" ] || mkdir -p "${ICON_DIR}"
for icon in alpine apple-logo arch centos debian \
fedora opensuse rocky tux ubuntu void
do
[ -f "${SCRIPT_PATH}"/icons/${icon}-${size}.png ] && {
cp "${SCRIPT_PATH}"/icons/${icon}-${size}.png "${ICON_DIR}"/${icon}.png
}
done
done
# Install JetBrains Mono font
if [ "${darwin}" ]; then
usr_font_dir="${HOME}/Library/Fonts"
else
usr_font_dir="${HOME}/.local/share/fonts"
fi
JB_FONT="NerdFonts/JetBrains Mono Bold Nerd Font Complete.ttf"
[ -f "${usr_font_dir}/${JB_FONT}" ] || install_fonts
# Fastfetch configuration
FAST_DIR="${HOME}/.config/fastfetch"
[ -d "${FAST_DIR}" ] || mkdir -p "${FAST_DIR}"
for cfg in ${SCRIPT_PATH}/fastfetch/config*
do
[ "${cfg}" == "${SCRIPT_PATH}/fastfetch/config*" ] && continue
ncfg=$(basename "${cfg}")
if [ -f "${FAST_DIR}"/${ncfg} ]; then
[ "${force}" ] && {
cat "${SCRIPT_PATH}"/fastfetch/${ncfg} | \
sed -e "s/__KITTY__/${fast_type}/" \
-e "s/__SIZE__/${icon_size}/g" \
-e "s/__PLATFORM__/${icon_name}/" > "${FAST_DIR}"/${ncfg}
}
else
cat "${SCRIPT_PATH}"/fastfetch/${ncfg} | \
sed -e "s/__KITTY__/${fast_type}/" \
-e "s/__SIZE__/${icon_size}/g" \
-e "s/__PLATFORM__/${icon_name}/" > "${FAST_DIR}"/${ncfg}
fi
done
# Neofetch configuration
NEOF_DIR="${HOME}/.config/neofetch"
[ -d "${NEOF_DIR}" ] || mkdir -p "${NEOF_DIR}"
for cfg in ${SCRIPT_PATH}/neofetch/config*
do
[ "${cfg}" == "${SCRIPT_PATH}/neofetch/config*" ] && continue
ncfg=$(basename "${cfg}")
if [ -f "${NEOF_DIR}"/${ncfg} ]; then
[ "${force}" ] && {
cp "${SCRIPT_PATH}"/neofetch/${ncfg} "${NEOF_DIR}"/${ncfg}
}
else
cp "${SCRIPT_PATH}"/neofetch/${ncfg} "${NEOF_DIR}"/${ncfg}
fi
done
printf "\nInstallation of kitty-control complete ✨ 🌟 ✨\n"
printf "\nSee ${REPO_URL}#readme\n\n"