The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Add A Random Quote Every time You Open A Terminal Window

TODO: Pull subtitle into page object

This is the code I put into my `~/.zshrc` file to pull a random quote at the top of my terminal each time I open a new one.

code_start_default_section code_end_default_section

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Add A Random Quote Every time You Open A Terminal Window

-- p

This is the code I put into my `~/.zshrc` file to pull a random quote at the top of my terminal each time I open a new one.

-- code/
-- bash

if [ "$(tput cols)" -gt 65 ]; then
    sort -R "/path/to/quotes.txt" | \
    head -1 | \
    sed 's/--/\n    --/' | \
    sed 's/$/\n/' | \
    fold -w 64 -s
else
    sort -R "/path/to/quotes.txt" | \
    head -1 | \
    sed 's/--/\n    --/' | \
    sed 's/$/\n/'                         
fi

-- /code

-- p

### Details

-- p

`sort -R FILENAME` randomized the lines in the file and sends them to STDOUT which pipes to:

-- p

`head -1` which grabs the first line from the randomized set which pipes to

-- p

the `sed` things which split the line out to separate the quote from the author and then add extra line spacing

-- p

And then if there are more than 65 columns (as determine by `if [ "$(tput cols)" -gt 65 ]`) then things are piped to:

-- p

`fold -w 64 -s`

-- p

which wraps lines at 64 characters

-- p

The other thing I do is drop an empty file at `~/.hushlogin` which prevents the message of the day from showing up. That way the only thing that shows in the quote.

-- p

Quotes are in the format:

-- code/
-- txt

Curiouser and curiouser! -- Alice
The death of an old person is like the burning of a library.  -- Traditional
Thank you for your patience during this emergency. -- Tech Support

-- /code


-- categories
-- Command Line

-- metadata
-- date: 2022-05-05 16:16:38
-- id: 28lcuceg
-- status: scratch
-- type: post
-- SCRUBBED_NEO: false
-- site: aws