-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmozumasu.sh
More file actions
executable file
·43 lines (34 loc) · 1 KB
/
Copy pathmozumasu.sh
File metadata and controls
executable file
·43 lines (34 loc) · 1 KB
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
#!/usr/bin/env bash
set -euo pipefail
IMAGE="${1:-./image.png}"
TEXT="${2:-Hey}"
IMG_W=30
IMG_H=12
GAP=2
FONT="slant"
V_ALIGN="bottom" # top|center|bottom
mapfile -t LINES < <(figlet -f "$FONT" -w 200 "$TEXT")
TEXT_H="${#LINES[@]}"
case "$V_ALIGN" in
top) PAD=0 ;;
bottom) PAD=$((IMG_H > TEXT_H ? IMG_H - TEXT_H : 0)) ;;
center) PAD=$((IMG_H > TEXT_H ? (IMG_H - TEXT_H) / 2 : 0)) ;;
*) PAD=0 ;;
esac
printf '\033[2J\033[H'
# (0,0) に画像を置く 位置指定は 0 起点
wezterm imgcat --position 0,0 --width "$IMG_W" --height "$IMG_H" "$IMAGE"
START_COL=$((IMG_W + GAP + 1))
START_ROW=$((1 + PAD))
# wezterm imgcat が出力する余計な数値をクリア(画像右側のテキスト領域のみ)
for ((r=1; r<=IMG_H; r++)); do
printf '\033[%d;%dH\033[K' "$r" "$START_COL"
done
# TrueColor 例: シアン
printf '\033[38;2;0;220;255m'
for i in "${!LINES[@]}"; do
row=$((START_ROW + i))
printf '\033[%d;%dH%s' "$row" "$START_COL" "${LINES[$i]}"
done
printf '\033[0m'
printf '\033[%d;1H' $((IMG_H + 2))