Last active
November 22, 2023 14:41
-
-
Save cartok/04012d01c5ce5d847547a867bdb040a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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