Guys,
I developed a script to help me read the output of pacman -Ss in 2 nicely
formatted columns. The output of 'pacman -Ss srchterm' drives me nuts trying to
read down the package names and descriptions with all the tab indented and
wrapped text -- so I fixed it. Download the script here:
http://www.3111skyline.com/dl/Archlinux/scripts/srch2list.sh
The script takes this:
extra/ttf-khmer 5.0-2
TTFont collection for Khmer (Cambodia)
extra/ttf-linux-libertine 4.4.1-3
Serif (Libertine) and Sans Serif (Biolinum) OpenType fonts with large
Unicode coverage
extra/ttf-mph-2b-damase 001.000.4.dfsg.2-2
Super-Unicode TTFont covering full Plane 1, and the following scripts:
Armenian, Buginese, Cherokee, Cypriot Syllabary, Cyrillic, Deseret, Georgian,
Asomtavruli, Nuskhuri but no Mkhedruli, Glagolitic, Gothic, Greek, Hanunoo,
Hebrew, Latin, Limbu, Linear B, Old Italic, Old Persian cuneiform, Osmanya,
Shavian, Syloti Nagri, Tai Le, Thaana, Tifinagh, Ugaritic, Vietnamese
extra/ttf-ms-fonts 2.0-3
Core TTF Fonts from Microsoft
and turn it into this:
ttf-khmer TTFont collection for Khmer (Cambodia)
ttf-linux-libertine Serif (Libertine) and Sans Serif
(Biolinum) OpenType fonts with large
Unicode coverage
ttf-mph-2b-damase Super-Unicode TTFont covering full
Plane 1, and the following scripts:
Armenian, Buginese, Cherokee, Cypriot
Syllabary, Cyrillic, Deseret, Georgian,
Asomtavruli, Nuskhuri but no Mkhedruli,
Glagolitic, Gothic, Greek, Hanunoo,
Hebrew, Latin, Limbu, Linear B, Old
Italic, Old Persian cuneiform, Osmanya,
Shavian, Syloti Nagri, Tai Le, Thaana,
Tifinagh, Ugaritic, Vietnamese
ttf-ms-fonts Core TTF Fonts from Microsoft
or with the '-d' option for semi-doublespace:
ttf-khmer TTFont collection for Khmer (Cambodia)
ttf-linux-libertine Serif (Libertine) and Sans Serif
(Biolinum) OpenType fonts with large
Unicode coverage
ttf-mph-2b-damase Super-Unicode TTFont covering full
Plane 1, and the following scripts:
Armenian, Buginese, Cherokee, Cypriot
Syllabary, Cyrillic, Deseret, Georgian,
Asomtavruli, Nuskhuri but no Mkhedruli,
Glagolitic, Gothic, Greek, Hanunoo,
Hebrew, Latin, Limbu, Linear B, Old
Italic, Old Persian cuneiform, Osmanya,
Shavian, Syloti Nagri, Tai Le, Thaana,
Tifinagh, Ugaritic, Vietnamese
ttf-ms-fonts Core TTF Fonts from Microsoft
The script needs 1 input. That is a filename 'srchfile' that contains the
output from 'pacman -Ss srchterm > srchfile' There are 2 options, '-h or --help'
gives a brief description and '-d' which causes the output to be essentially
double-spaced. (each package description remains single spaced if it requires
multiple lines, but a blank line is included between package descriptions) On
the todo list is having the script take the input from stdin and eliminate the
srchfile.
NOTE: the '-d' option goes AFTER the filename.
(I'll make the cli input position independent in the next version)
The script does some pretty cool stuff and has some of my favorite funtions for
the bash addicts out there. It reads 'srchfile' and formats the output in two
columns 'pkgname' and 'description'. The pkgname column width is adjusted to the
longest filename and the description column (in multiple lines, if necessary)
spans the remainder of the xterm width leaving a one-char margin on the right.
To make reading easier the description is parsed before being output so that
descriptions that span multiple lines only break on spaces and not words while
staying withing the column width. The column widths are dynamic based on the
terminal window size. (via obtaining the terminal width and height from stty
output). (for some reason, $COLUMNS and $LINES are not available in my scripts??
environment? exports?)
The script was fun to write as it incorporated a good many of the finer points
of bash. It is also well commented so if you are learning bash, or want to
learn, this script can be a useful tool for some of the cooler things that can
be done with arrays and strings using index manipulation and substring
parsing/parameter substitution.
The ultimate goal was to make the pacman search output readable, and I think
this makes reading the search results *much* easier, at least for me.
I guess what I should do for the next version is just incorporate the pacman
-Ss call into the script itself and simply read the output of the search
directly into the input array instead of reading the input file into an array.
Simple enough, but I'll have to put that out as the next revision.
Give this a whirl and see what you think. Let me know what works and what
doesn't and also how I do things better/cleaner than I have currently done them.
Who knows, maybe we will look at 'zenity --list' and provide a gui output next
time :p
Enjoy.
--
David C. Rankin, J.D.,P.E.
Rankin Law Firm, PLLC
510 Ochiltree Street
Nacogdoches, Texas 75961
Telephone: (936) 715-9333
Facsimile: (936) 715-9339
www.rankinlawfirm.com