zshrc: cowsay Cowfiles dynamisch filtern (macOS-Kompatibilitaet)
Auf macOS (Homebrew) fehlt die 'gnu' Cowfile, was beim Login zu "Could not find cowfile for 'gnu'!" fuehrte. Cowfiles werden jetzt gegen die tatsaechlich installierten geprueft.
This commit is contained in:
parent
1fa8e777d5
commit
6b9658ab1d
1 changed files with 7 additions and 1 deletions
|
|
@ -175,7 +175,13 @@ TRAPALRM() {
|
||||||
# Begruessung: zufaellig Systemstatus, Spruch oder Witz
|
# Begruessung: zufaellig Systemstatus, Spruch oder Witz
|
||||||
if [[ -o interactive ]] && command -v cowsay &>/dev/null; then
|
if [[ -o interactive ]] && command -v cowsay &>/dev/null; then
|
||||||
_greet() {
|
_greet() {
|
||||||
local cow_files=(default tux sheep elephant dragon gnu koala)
|
local all_cows=(default tux sheep elephant dragon gnu koala)
|
||||||
|
local cow_files=()
|
||||||
|
local cowpath=$(cowsay -l 2>/dev/null | tail -n +2 | tr ' ' '\n')
|
||||||
|
for c in "${all_cows[@]}"; do
|
||||||
|
echo "$cowpath" | grep -qx "$c" && cow_files+=("$c")
|
||||||
|
done
|
||||||
|
(( ${#cow_files[@]} == 0 )) && cow_files=(default)
|
||||||
local cow="${cow_files[$((RANDOM % ${#cow_files[@]} + 1))]}"
|
local cow="${cow_files[$((RANDOM % ${#cow_files[@]} + 1))]}"
|
||||||
case $((RANDOM % 3)) in
|
case $((RANDOM % 3)) in
|
||||||
0) # Systemstatus
|
0) # Systemstatus
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue