I once felt a desperate need for a lorem impsum generator (if you do not know lorem ipsum is see [1]) that runs from the console. When I was unable to find one I had to build it myself.

http://www.pererikstrandberg.se/blog/screenshot-lorem-ipsum.png

Get the latest version here: [2]

You need python to run it (see [3]).

If you are a windows user you might want to rename the file from 'lorem' to 'lorem.py' and you will probably need to run it with "python lorem.py -n 25" instead of the *nix way: "lorem -n 25".

Documentation

Usage:    lorem [-n|-l|-c] N [-q M]?
          where
          N and M are integers

Note:     If -n -l and/or -c are combined -l has priority over -c that has
          priority over -n.

Examples: lorem -n 10
          Get 10 words of lorem.

          lorem -l 5
          Get 5 lines of lorem

          lorem -c 79
          Get 79 characters of lorem

          lorem -l 5 -q 11
          Get 5 lines of lorem from quote 11

License:  Copyright (C) 2007 Per Erik Strandberg
          This program comes with ABSOLUTELY NO WARRANTY.

          This is free software, and you are welcome to redistribute it
          under the GNU GENERAL PUBLIC LICENSE Version 3.  


Options:
  --version   show program's version number and exit
  -h, --help  show this help message and exit
  -n N        Number of Words
  -l L        Number of Lines
  -c C        Number of Chars
  -q Q        Quote index 

Examples

Also see the screenshot above - to see what it looks like "for real" [:)]-|--< .

Fifty words

The switch -n is for words and we want fifty of them. So this gives us fifty words.

>lorem -n 50
lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat sed diam voluptua at
vero eos et accusam et justo duo dolores et ea rebum stet clita kasd gubergren
no sea takimata sanctus est lorem ipsum dolor sit amet

(Location of line breaks may vary - there are none in the real output.)

Five lines

The switch -l is for lines. The switch -q is for quote index (there are about 13 different sources). Values of -q should be from 0 and up. Too large values result in a text written by me (it is all variations of foobar).

So for five lines from source with index 1 this is what you should write:

>lorem -l 5 -q 1
oh thou in hellas deemed of heavenly birth
muse formed or fabled at the minstrels will
since shamed full oft by later lyres on earth
mine dares not call thee from thy sacred hill
yet there ive wandered by thy vaunted rill

79 characters

Last switch is -c for characters (spaces count as characters). It can be used like this:

>lorem -c 79 -q 11
me quedo con el transparente hombrecillo que come los huevos de la golondrina m


Please note that piping this to a file results in a file with one more character than you might first expect:

First we create a file with the output from 'lorem -c 15'

>lorem -c 15 > /tmp/lorem15.txt

Next we run the command 'wc' (word count) with the switch -c. This means that characters will be counted

>wc -c  /tmp/lorem15.txt
16 /tmp/lorem15.txt

wc says we have 16 characters - that is annoying. But let us look at the hexdump of it using 'hd':

>hd /tmp/lorem15.txt
00000000  6c 6f 72 65 6d 20 69 70  73 75 6d 20 64 6f 6c 0a  |lorem ipsum dol.|
00000010

As you can see there are 15 characters of lorem and then a new-line character.

Quote indices

0 - Lorem ipsum, Cicero
1 - Childe Harold's Pilgrimage - Canto the first (I.-X.), Lord Byron
2 - Decameron - Novella Prima, Giovanni Boccaccio
3 - Faust: Der Tragödie erster Teil, Johann Wolfgang von Goethe
4 - In der Fremde, Heinrich Heine
5 - Le Bateau Ivre, Arthur Baudelaire
6 - Le Masque, Arthur Rembaud
7 - Nagyon fáj, József Attila
8 - Ómagyar-Mária siralom, Ismeretlen
8 - Robinsono Kruso (Esperanto), Daniel Defoe
9 - The Raven, Edgar Allan Poe
10 - Tierra y Luna, Federico García Lorca
11 - Hemsöborna, August Strindberg
12 - Random Foobar, Per Erik Strandberg

Non-Ascii Characters like åäö

Some of the quote sources have "exotic" characters in them (non-ascii characters). In lorem 0.5 for example the quote with index 12 is the start of August Strindbergs Hemsöborna. This is what it should look like in the terminal:

>lorem -n 16 -q 12
han kom som ett yrväder en aprilafton och hade ett höganäskrus i en svångrem om halsen

In my gnome-terminal it looks something like this but with really ugly ?'s:

>lorem -n 16 -q 12
han kom som ett yrv?der en aprilafton och hade ett h?gan?skrus i en sv?ngrem om halsen

But if I pipe it to file like so:

>lorem -n 16 -q 12 > /tmp/strind.txt 

The file contains the correct characters. This is what the file looks like in Gnu Emacs:
http://www.pererikstrandberg.se/blog/screenshot-lorem-strindberg.png

So it might just be a problem with encodings or so - I really do not know. Also: if you modify this file make sure you do so in an editor that supports non-ascii characters or these exotic quotes will be ruined.

Details

This Lorem Ipsum Generator (lorem) is Copyright (C) 2007 Per Erik Strandberg, it is also free software, and you are welcome to redistribute it under the GNU General Public License v 3 (see [4]). lorem comes with NO WARRANTY, to the extent permitted by law.


This page belongs in Kategori Programmering.