Install banner deps and prompt for punchline
This commit is contained in:
10
README.md
10
README.md
@@ -43,9 +43,9 @@ dotfiles/
|
|||||||
|
|
||||||
På Linux/WSL lastes også et banner ved login:
|
På Linux/WSL lastes også et banner ved login:
|
||||||
|
|
||||||
- `figlet $(hostname)` i farger
|
- `figlet $(hostname) -c | lolcat`
|
||||||
- `figlet -f digital "<punchline>"` i farger
|
- `figlet -f digital "<punchline>" -c | lolcat`
|
||||||
- `landscape-sysinfo` (hvis tilgjengelig)
|
- `landscape-sysinfo | lolcat`
|
||||||
|
|
||||||
### Punchline (global)
|
### Punchline (global)
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ Banneret leser punchline fra:
|
|||||||
|
|
||||||
- `/etc/ps1-punchline`
|
- `/etc/ps1-punchline`
|
||||||
|
|
||||||
Sett punchline slik:
|
Install-scriptet spør etter punchline og lagrer den i filen. Du kan også sette den manuelt:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
echo "Din punchline" | sudo tee /etc/ps1-punchline >/dev/null
|
echo "Din punchline" | sudo tee /etc/ps1-punchline >/dev/null
|
||||||
@@ -73,6 +73,8 @@ This:
|
|||||||
|
|
||||||
- Installs the prompt module to `/etc/profile.d/ps1.sh`
|
- Installs the prompt module to `/etc/profile.d/ps1.sh`
|
||||||
- Sources it in `/etc/bash.bashrc` so all users get the prompt
|
- Sources it in `/etc/bash.bashrc` so all users get the prompt
|
||||||
|
- Installs `landscape-common`, `figlet`, and `lolcat` if missing
|
||||||
|
- Prompts for the global punchline used by the banner
|
||||||
- After install, open a new shell to see the prompt
|
- After install, open a new shell to see the prompt
|
||||||
|
|
||||||
### 🍏 macOS (per-user)
|
### 🍏 macOS (per-user)
|
||||||
|
|||||||
@@ -47,22 +47,19 @@ if [[ -r /etc/ps1-punchline ]]; then
|
|||||||
PUNCHLINE="${PUNCHLINE%%$'\r'}"
|
PUNCHLINE="${PUNCHLINE%%$'\r'}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print banner (only if figlet exists)
|
# Print banner + sysinfo
|
||||||
if [[ -n "${FIGLET:-}" ]]; then
|
if [[ -n "${FIGLET:-}" ]]; then
|
||||||
if [[ "$HAVE_LOLCAT" -eq 1 ]]; then
|
if [[ "$HAVE_LOLCAT" -eq 1 ]]; then
|
||||||
"$FIGLET" "$(hostname)" -c | "$LOLCAT"
|
"$FIGLET" "$(hostname)" -c | "$LOLCAT"
|
||||||
"$FIGLET" -f digital "$PUNCHLINE" -c | "$LOLCAT"
|
"$FIGLET" -f digital "$PUNCHLINE" -c | "$LOLCAT"
|
||||||
|
if [[ -n "${LANDSCAPE:-}" ]]; then
|
||||||
|
"$LANDSCAPE" | "$LOLCAT"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
"$FIGLET" "$(hostname)" -c
|
"$FIGLET" "$(hostname)" -c
|
||||||
"$FIGLET" -f digital "$PUNCHLINE" -c
|
"$FIGLET" -f digital "$PUNCHLINE" -c
|
||||||
fi
|
if [[ -n "${LANDSCAPE:-}" ]]; then
|
||||||
fi
|
"$LANDSCAPE"
|
||||||
|
fi
|
||||||
# Print sysinfo if available (Linux)
|
|
||||||
if [[ -n "${LANDSCAPE:-}" ]]; then
|
|
||||||
if [[ "$HAVE_LOLCAT" -eq 1 ]]; then
|
|
||||||
"$LANDSCAPE" | "$LOLCAT"
|
|
||||||
else
|
|
||||||
"$LANDSCAPE"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -20,6 +20,57 @@ BASH_BASHRC="/etc/bash.bashrc"
|
|||||||
MARKER_START="# >>> dotfiles (managed) >>>"
|
MARKER_START="# >>> dotfiles (managed) >>>"
|
||||||
MARKER_END="# <<< dotfiles (managed) <<<"
|
MARKER_END="# <<< dotfiles (managed) <<<"
|
||||||
|
|
||||||
|
# Ensure required packages are installed (no prompt)
|
||||||
|
missing_pkgs=()
|
||||||
|
if ! command -v figlet >/dev/null 2>&1; then
|
||||||
|
missing_pkgs+=("figlet")
|
||||||
|
fi
|
||||||
|
if ! command -v lolcat >/dev/null 2>&1 && [[ ! -x /usr/games/lolcat ]]; then
|
||||||
|
missing_pkgs+=("lolcat")
|
||||||
|
fi
|
||||||
|
if ! command -v landscape-sysinfo >/dev/null 2>&1; then
|
||||||
|
missing_pkgs+=("landscape-common")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ((${#missing_pkgs[@]} > 0)); then
|
||||||
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
|
apt-get update
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install -y "${missing_pkgs[@]}"
|
||||||
|
elif command -v dnf >/dev/null 2>&1; then
|
||||||
|
dnf install -y "${missing_pkgs[@]}"
|
||||||
|
elif command -v yum >/dev/null 2>&1; then
|
||||||
|
yum install -y "${missing_pkgs[@]}"
|
||||||
|
elif command -v pacman >/dev/null 2>&1; then
|
||||||
|
pacman -Sy --noconfirm "${missing_pkgs[@]}"
|
||||||
|
elif command -v zypper >/dev/null 2>&1; then
|
||||||
|
zypper -n in "${missing_pkgs[@]}"
|
||||||
|
else
|
||||||
|
echo "Fant ingen støttet pakkehåndterer for å installere: ${missing_pkgs[*]}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prompt for punchline (stored globally)
|
||||||
|
current_punchline="Hello"
|
||||||
|
if [[ -r /etc/ps1-punchline ]]; then
|
||||||
|
current_punchline="$(head -n 1 /etc/ps1-punchline 2>/dev/null || echo "Hello")"
|
||||||
|
current_punchline="${current_punchline%%$'\r'}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -t 0 ]]; then
|
||||||
|
echo "Punchline (enter for å beholde eksisterende):"
|
||||||
|
read -r -p "> " new_punchline
|
||||||
|
else
|
||||||
|
new_punchline=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${new_punchline}" ]]; then
|
||||||
|
printf '%s\n' "${new_punchline}" > /etc/ps1-punchline
|
||||||
|
else
|
||||||
|
printf '%s\n' "${current_punchline}" > /etc/ps1-punchline
|
||||||
|
fi
|
||||||
|
chmod 0644 /etc/ps1-punchline
|
||||||
|
|
||||||
# Copy modules
|
# Copy modules
|
||||||
cp -f "$SRC_PS1" "$DST_PS1"
|
cp -f "$SRC_PS1" "$DST_PS1"
|
||||||
chmod 0644 "$DST_PS1"
|
chmod 0644 "$DST_PS1"
|
||||||
|
|||||||
Reference in New Issue
Block a user