summaryrefslogtreecommitdiff
path: root/.old/lipsum
diff options
context:
space:
mode:
Diffstat (limited to '.old/lipsum')
-rwxr-xr-x.old/lipsum87
1 files changed, 0 insertions, 87 deletions
diff --git a/.old/lipsum b/.old/lipsum
deleted file mode 100755
index 7ae9b7e..0000000
--- a/.old/lipsum
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/awk -f
-
-function printusage() {
- print "Usage: lipsum [# of] [w/words|s/sentences|p/paragraphs] [1/t/true|0/f/false output 'lorem ipsum' in first entry] [min words] [max words]\n"
- exit 1
-}
-
-function capitalize() {
- sub(/./, toupper(substr($0, 0, 1)))
-}
-
-function randrange(min, max) {
- return int((rand() * (max - min)) + min)
-}
-
-function isint(arg) {
- return arg ~ /^[0-9]+$/
-}
-
-function genwords(words, cmd) {
- if (words > 0 && cmd | getline) {
- capitalize(); print
- for (i = 1; cmd | getline && i < words; i++)
- print " "$0
- print "\n"
- }
-}
-
-function gensentences(sentences, delim, cmd, min, max) {
- for (; sentences > 0 && cmd | getline; sentences--) {
- capitalize(); print
- words = randrange(min, max) # Isn't possible to initialize or increment multiple variables in awk for loops
- for (i = 1; cmd | getline && i < words; i++)
- print (rand() < 0.10 ? ", " : " ")$0
- print delim
- }
-}
-
-function genparagraphs(paragraphs, cmd, min, max) {
- for (; paragraphs > 0; paragraphs--) {
- print "\t"
- gensentences(randrange(6, 10), ". ", cmd, min, max)
- print "\n"
- }
-}
-
-BEGIN {
- dictionary = "/home/timmy/.local/share/lorem-ipsum-dictionary" # List of lorem ipsum words separated by newlines
- cmd = "< "dictionary" shuf -r -n" # Command to generate random permutations of words from dictionary separated by newlines
- echolorem = "echo -n 'lorem\nipsum\ndolor\nsit\namet\n'"
-
- ORS = ""
- srand()
-
- # Parse Arguments
- !isint(ARGV[1]) && ARGV[1] && printusage()
- numof = ARGC > 1 ? ARGV[1] : 5
- mode = ARGC > 2 ? ARGV[2] : "p"
- litext = 1
- if (ARGV[3])
- switch (ARGV[3]) {
- case /^1$|^t$|^true$/: litext = 1; break
- case /^0$|^f$|^false$/: litext = 0; break
- default: printusage()
- }
- litext && cmd = echolorem "&&" cmd
- min = isint(ARGV[4]) ? ARGV[4] : 5
- max = isint(ARGV[5]) ? ARGV[5] : 12
-
- switch (mode) {
- case /^w$|^words$/:
- cmd = cmd numof
- genwords(numof, cmd)
- break
- case /^s$|^sentences$/:
- cmd = cmd (max * numof)
- gensentences(numof, ".\n", cmd, min, max)
- break
- case /^p$|^paragraphs$/:
- cmd = cmd (max * 10 * numof)
- genparagraphs(numof, cmd, min, max)
- break
- default:
- printusage()
- }
- close(cmd)
-}