This commit is contained in:
2026-01-24 05:25:45 +00:00
parent 73c54192f7
commit ee39628557
3 changed files with 81 additions and 132 deletions

58
dotfiles/banner/banner.sh Normal file
View File

@@ -0,0 +1,58 @@
#!/usr/bin/env bash
# Banner module (global/user). Runs once per login session.
case "$-" in
*i*) ;;
*) return 0 ;;
esac
# Disable switch (per-user/per-shell)
# 1) env: DISABLE_GLOBAL_BANNER=1
# 2) file: ~/.config/ps1/disable-banner
if [[ "${DISABLE_GLOBAL_BANNER:-0}" == "1" ]]; then
return 0
fi
if [[ -f "$HOME/.config/ps1/disable-banner" ]]; then
return 0
fi
# Run banner only once per session
if [[ -n "${__BANNER_ALREADY_SHOWN:-}" ]]; then
return 0
fi
__BANNER_ALREADY_SHOWN=1
# Find tools (be defensive)
FIGLET="$(command -v figlet 2>/dev/null || true)"
LANDSCAPE="$(command -v landscape-sysinfo 2>/dev/null || true)"
# lolcat is often /usr/games/lolcat on Ubuntu
if [[ -x /usr/games/lolcat ]]; then
LOLCAT="/usr/games/lolcat"
else
LOLCAT="$(command -v lolcat 2>/dev/null || true)"
fi
# If lolcat missing, fallback to cat (no color)
if [[ -z "${LOLCAT:-}" ]]; then
LOLCAT="cat"
fi
# Punchline source:
# - global file: /etc/ps1-punchline
# - fallback: "Hello"
PUNCHLINE="Hello"
if [[ -r /etc/ps1-punchline ]]; then
PUNCHLINE="$(cat /etc/ps1-punchline 2>/dev/null || echo "Hello")"
fi
# Print banner (only if figlet exists)
if [[ -n "${FIGLET:-}" ]]; then
"$FIGLET" "$(hostname)" -c | "$LOLCAT"
"$FIGLET" -f digital "$PUNCHLINE" -c | "$LOLCAT"
fi
# Print sysinfo if available (Linux)
if [[ -n "${LANDSCAPE:-}" ]]; then
"$LANDSCAPE" | "$LOLCAT"
fi