Skip to content

Instantly share code, notes, and snippets.

@cartok
Last active November 22, 2023 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cartok/04012d01c5ce5d847547a867bdb040a5 to your computer and use it in GitHub Desktop.
Save cartok/04012d01c5ce5d847547a867bdb040a5 to your computer and use it in GitHub Desktop.
function loremipsum() {
# TODO: Extract wblp from $1 to allow 2w, 5w, 3p, 6l etc. WIP: FOO=20asdrf; echo ${FOO%%[a-z]*}
local amount=${1:-1}
# set -x
# local foo=${amount%%[a-z]+}
# echo $foo
# exit 1
# Working values for the "what" parameter: "words", "paras", "bytes"
local what=${2:-paras}
if [[ $2 == "word" || $2 == "w" ]]; then
local what="words"
fi
if [[ $2 == "byte" || $2 == "b" ]]; then
local what="bytes"
fi
if [[ $2 == "list" || $2 == "l" ]]; then
local what="lists"
fi
if [[ $2 == "paragraph" || $2 == "paragraphs" || $2 == "p" ]]; then
local what="paras"
fi
local result=$(\
curl -s -X POST https://lipsum.com/feed/json -d amount=$amount -d what=$what \
| jq -r '.feed.lipsum' \
| xargs -I {} zsh -c 'echo "\n{}"' \
| tail -n +2
)
echo $result
wl-copy $result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment