-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfiglet-list.sh
executable file
·50 lines (40 loc) · 1.42 KB
/
figlet-list.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
#!/usr/bin/env bash
# =============================================================================
# Script to display all toilet/figlet fonts with sample text
# =============================================================================
# It will try /usr/share/figlet and /usr/share/figlet/fonts. I got extra fonts
# installed in the latter.
# Refs:
# =============================================================================
# https://github.com/xero/figlet-fonts
# https://github.com/xero/dotfiles
TOILET_FONT_PATH=${TOILET_FONT_PATH:=/usr/share/figlet}
FIGLET_FONTS_PATH="/usr/share/figlet/fonts"
PAGER=${PAGER:=less}
process_fonts_from_dir() {
local dir=$1
if [[ ! -d "$dir" ]]; then
echo "Directory not found: $dir"
return
fi
echo "=== Fonts from $dir ==="
echo ""
# Loop through all toilet and figlet font files
for i in "${dir}"/*.{t,f}lf; do
# Skip if no matches were found (happens when the glob doesn't match any files)
[[ -e "$i" ]] || continue
# Extract just the filename from the path
file=${i##*/}
name=${file%.*}
dir=${i%/*}
echo ""
echo "╓───── $file"
echo "╙────────────────────────────────────── ─ ─ "
echo ""
toilet -d "$dir" -f "$file" "$name"
done
}
{
process_fonts_from_dir "$TOILET_FONT_PATH"
process_fonts_from_dir "$FIGLET_FONTS_PATH"
} | "$PAGER"