From 874c7910d584f6888ca3fcca63488bba858fd02a Mon Sep 17 00:00:00 2001 From: steffen Date: Sat, 24 Jan 2026 05:57:54 +0000 Subject: [PATCH] . --- dotfiles/banner/banner.sh | 24 +++++++++++++++++------- dotfiles/install/install-linux-global.sh | 10 +++++++++- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/dotfiles/banner/banner.sh b/dotfiles/banner/banner.sh index a700e00..e0f6b35 100644 --- a/dotfiles/banner/banner.sh +++ b/dotfiles/banner/banner.sh @@ -33,9 +33,9 @@ else LOLCAT="$(command -v lolcat 2>/dev/null || true)" fi -# If lolcat missing, fallback to cat (no color) -if [[ -z "${LOLCAT:-}" ]]; then - LOLCAT="cat" +HAVE_LOLCAT=0 +if [[ -n "${LOLCAT:-}" ]]; then + HAVE_LOLCAT=1 fi # Punchline source: @@ -43,16 +43,26 @@ fi # - fallback: "Hello" PUNCHLINE="Hello" if [[ -r /etc/ps1-punchline ]]; then - PUNCHLINE="$(cat /etc/ps1-punchline 2>/dev/null || echo "Hello")" + PUNCHLINE="$(head -n 1 /etc/ps1-punchline 2>/dev/null || echo "Hello")" + PUNCHLINE="${PUNCHLINE%%$'\r'}" fi # Print banner (only if figlet exists) if [[ -n "${FIGLET:-}" ]]; then - "$FIGLET" "$(hostname)" -c | "$LOLCAT" - "$FIGLET" -f digital "$PUNCHLINE" -c | "$LOLCAT" + if [[ "$HAVE_LOLCAT" -eq 1 ]]; then + "$FIGLET" "$(hostname)" -c | "$LOLCAT" + "$FIGLET" -f digital "$PUNCHLINE" -c | "$LOLCAT" + else + "$FIGLET" "$(hostname)" -c + "$FIGLET" -f digital "$PUNCHLINE" -c + fi fi # Print sysinfo if available (Linux) if [[ -n "${LANDSCAPE:-}" ]]; then - "$LANDSCAPE" | "$LOLCAT" + if [[ "$HAVE_LOLCAT" -eq 1 ]]; then + "$LANDSCAPE" | "$LOLCAT" + else + "$LANDSCAPE" + fi fi diff --git a/dotfiles/install/install-linux-global.sh b/dotfiles/install/install-linux-global.sh index e3bc7a5..18cce8c 100644 --- a/dotfiles/install/install-linux-global.sh +++ b/dotfiles/install/install-linux-global.sh @@ -29,12 +29,18 @@ chmod 0644 "$DST_BANNER" # Ensure /etc/bash.bashrc sources both (idempotent) tmp="$(mktemp)" +orig_mode="$(stat -c '%a' "$BASH_BASHRC")" +orig_owner="$(stat -c '%u' "$BASH_BASHRC")" +orig_group="$(stat -c '%g' "$BASH_BASHRC")" awk -v s="$MARKER_START" -v e="$MARKER_END" ' $0==s {inside=1; next} $0==e {inside=0; next} !inside {print} ' "$BASH_BASHRC" > "$tmp" -cat "$tmp" > "$BASH_BASHRC" +install -m "$orig_mode" -o "$orig_owner" -g "$orig_group" "$tmp" "$BASH_BASHRC" +if command -v restorecon >/dev/null 2>&1; then + restorecon "$BASH_BASHRC" >/dev/null 2>&1 || true +fi rm -f "$tmp" cat >> "$BASH_BASHRC" <