Added custom quotes to login

Pull quotes from text file online, choose one and display it with
optional `cowsay and `lolcat` at each login.
This commit is contained in:
2024-02-18 18:55:52 -05:00
parent acadd11016
commit 287aed455a
2 changed files with 43 additions and 1 deletions

2
.zshrc
View File

@@ -12,7 +12,7 @@ source $ZSH/oh-my-zsh.sh
[[ ! -f ~/.shell_functions ]] || source ~/.shell_functions
[[ ! -f ~/.shell_aliases ]] || source ~/.shell_aliases
fortune -a | cowsay | lolcat
$HOME/dotfiles-zsh/get-quote.sh
# Instant Prompt Preamble
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.

42
get-quote.sh Executable file
View File

@@ -0,0 +1,42 @@
#!/usr/bin/env bash
#===============================================================================
#
# FILE:
# USAGE:
# DESCRIPTION:
# REQUIREMENTS:
# NOTES:
# AUTHOR: C Hawley
# CREATED:
#
#===============================================================================
# URL of the text file
TEXT_FILE_URL="https://files.planethawleywood.com/quotes.txt"
# Download the text file using curl and store it in a temporary file
temp_file=$(mktemp)
curl -s "$TEXT_FILE_URL" > "$temp_file"
# Count the number of lines in the file
num_lines=$(wc -l < "$temp_file")
# Generate a random line number
random_line=$(( (RANDOM % num_lines) + 1))
# Display the random line
quote=$(sed -n "${random_line}p" "$temp_file")
# cowsay and lolcat if available
if [[ $(command -v cowsay) ]]; then
if [[ $(command -v lolcat) ]]; then
cowsay -f tux "${quote}" | lolcat
else
cowsay -f tux "${quote}"
fi
else
echo "${quote}"
fi
# remove temp file
rm $temp_file