From a192f828af17ebdaf5720b984cc538cb3766a04e Mon Sep 17 00:00:00 2001 From: chawley Date: Mon, 7 Apr 2025 18:56:44 -0400 Subject: [PATCH] Updated dotfiles-zsh Added random quote lines directly to .zshrc, updated README, commented create-links and removed separate quote script --- .zshrc | 21 ++++++++++++++++++++- README.md | 2 ++ create-links.sh | 1 + get-quote.sh | 42 ------------------------------------------ 4 files changed, 23 insertions(+), 43 deletions(-) delete mode 100755 get-quote.sh diff --git a/.zshrc b/.zshrc index 474f5ef..dff72c7 100644 --- a/.zshrc +++ b/.zshrc @@ -33,7 +33,26 @@ setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording en setopt HIST_VERIFY # Don't execute immediately upon history expansion. setopt HIST_BEEP # Beep when accessing nonexistent history. -$HOME/dotfiles-zsh/get-quote.sh +# Display Random Quote +if command -v curl >/dev/null 2>&1; then + QUOTE=$(curl -s https://files.planethawleywood.com/quotes.txt) + if [ -n "$QUOTE" ]; then + if command -v shuf >/dev/null 2>&1; then + QUOTE=$(echo "$QUOTE" | shuf -n 1) + fi + if command -v cowsay >/dev/null 2>&1; then + if command -v lolcat >/dev/null 2>&1; then + echo "$QUOTE" | cowsay -f tux | lolcat + else + echo "$QUOTE" | cowsay -f tux + fi + elif command -v lolcat >/dev/null 2>&1; then + echo "$QUOTE" | lolcat + else + echo "$QUOTE" + fi + fi +fi # Instant Prompt Preamble # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. diff --git a/README.md b/README.md index 1393303..667f080 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,5 @@ Just a place to track my ZSH configs Including `.zshrc`, `.fzf.zsh` and settings for [oh-my-zsh ](https://github.com/robbyrussell/oh-my-zsh) (required) + +Includes `.zshrc.original` as a working reference since I've changed mine so much. diff --git a/create-links.sh b/create-links.sh index f153cd1..215708f 100755 --- a/create-links.sh +++ b/create-links.sh @@ -19,5 +19,6 @@ [[ -L $HOME/.zshrc ]] && unlink $HOME/.zshrc [[ -L $HOME/.fzf.zsh ]] && unlink $HOME/.fzf.zsh +# Create symlinks to files in repository ln -s $PWD/.zshrc $HOME/.zshrc ln -s $PWD/.fzf.zsh $HOME/.fzf.zsh diff --git a/get-quote.sh b/get-quote.sh deleted file mode 100755 index f490a8a..0000000 --- a/get-quote.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/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