-
Notifications
You must be signed in to change notification settings - Fork 0
/
new2-update-markdown-help-files.sh
executable file
·46 lines (40 loc) · 1.89 KB
/
new2-update-markdown-help-files.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
#!/bin/bash
# Check if glow is installed
if ! command -v glow >/dev/null 2>&1; then
# Create the directory for keyrings if it doesn't exist
sudo mkdir -p /etc/apt/keyrings
# Add the Charm keyring
curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
# Add the Charm repository
echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
# Update package lists and install glow
sudo apt update && sudo apt install -y glow
fi
# Remove every h-* file in /usr/local/bin that contains "glow -p"
for file in /usr/local/bin/h-*; do
if [ -f "$file" ] && grep -q "glow -p" "$file"; then
sudo rm -f "$file"
fi
done
# Ensure every ./0-help/h-* is chmod +x
for file in ./0-help/h-*; do
if [ -f "$file" ]; then
chmod +x "$file"
fi
done
# Copy every ./0-help/h-* to /usr/local/bin
for file in ./0-help/h-*; do
if [ -f "$file" ]; then
sudo cp -f "$file" /usr/local/bin/
fi
done
echo "Markdown help files installed to /usr/local/bin/ (which is in \$PATH)"
echo "Type h- then press Tab twice to see available markdown help files."
# We use /usr/local/bin becasue it is a standard directory used for user-installed executable programs.
# By convention, /usr/local/bin is used to store programs that the system administrator installs
# locally (manually) rather than through the package manager. This helps keep these programs separate
# from those installed by the system package manager. Also, it is a common location across almost all
# Linux distributions, so is a portable and consistent location for these help files
# User Permissions: It provides a clear distinction between system-managed binaries in /usr/bin and
# /bin, and locally-managed binaries in /usr/local/bin. This ensures that local changes do not
# interfere with system-managed software.