Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-10 Thread David C. Rankin

On 08/05/2010 10:51 PM, David C. Rankin wrote:

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


snip


Enjoy.



I have played with the script a bit more so it provides the option to only show 
installed or uninstalled packages to minimize the stuff to look through. The 
current options to the script are:


  Options:

NOTE: options can be given in any order, flags must be separate: '-d -z' 
NOT '-dz'


-c | --color   disable the use of an accent color for pkgnames.
-d | --double  option controls single/double spaced output.
-h | --helpdisplay this help message.
-i | --installed   show only installed packages.
-u | --uninstalled show only uninstalled packages.
-w | --write filename  write search results to 'filename'.
-z | --zenity  provide graphical output using 'zenity --list' 
(requires zenity)


  Two additional testing options (no effect on script):

-v | --verbose dump select variables to the screen.
-a | --array   dump the array contents to the screen (requires -v 
option)




--
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


Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-10 Thread David C. Rankin

On 08/10/2010 03:46 PM, David C. Rankin wrote:

On 08/05/2010 10:51 PM, David C. Rankin wrote:

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


snip


Enjoy.



I have played with the script a bit more so it provides the option to only show
installed or uninstalled packages to minimize the stuff to look through. The
current options to the script are:

Options:

NOTE: options can be given in any order, flags must be separate: '-d -z' NOT 
'-dz'

-c | --color disable the use of an accent color for pkgnames.
-d | --double option controls single/double spaced output.
-h | --help display this help message.
-i | --installed show only installed packages.
-u | --uninstalled show only uninstalled packages.
-w | --write filename write search results to 'filename'.
-z | --zenity provide graphical output using 'zenity --list' (requires zenity)

Two additional testing options (no effect on script):

-v | --verbose dump select variables to the screen.
-a | --array dump the array contents to the screen (requires -v option)





Version 0.0.4

  Changelog:

  - No functional changes - code clean up moving output routine to a function
for readability.

  Todo:

  - Capture zenity package selection so selected packages can be automatically
installed. (basically provide: pacman -Sy 'selected packages')


--
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


Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-10 Thread David C. Rankin

On 08/10/2010 05:29 PM, David C. Rankin wrote:

On 08/10/2010 03:46 PM, David C. Rankin wrote:

On 08/05/2010 10:51 PM, David C. Rankin wrote:

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


snip




	Whew - I have finally worked out the zenity install routine and I like it. I 
have also added the -n | --notext option that suppresses output of the list of 
search packages to the console. It is primarily for use with the -z | --zenity 
switch to allow the program to be run as a graphical program. Try it:


srch2list.sh srchterm (or saved filename) -z -n

and this will provide a graphical list with a checkbox for each package. You can 
select any number of packages you would like to install. Clicking 'Cancel' 
exits. Clicking 'OK' will bring up a confirmation dialog with the selected 
packages so the user can confirm the install --or-- modify the selection. 
Clicking 'Cancel' will again exit. Clicking 'OK' here will call pacman -Sy list 
of packages or will try 'sudo pacman' if run by other than root.


The new option list is:

  Options:

NOTE: options can be given in any order, flags must be separate: '-d -z' 
NOT '-dz'


-c | --color   disable the use of an accent color for pkgnames.
-d | --double  option controls single/double spaced output.
-h | --helpdisplay this help message.
-i | --installed   show only installed packages.
-n | --notext  don't output list to console (use with -z).
-u | --uninstalled show only uninstalled packages.
-w | --write filename  write search results to 'filename'.
-z | --zenity  provide graphical output using 'zenity --list' 
(requires zenity)


  Two additional testing options (no effect on script):

-v | --verbose dump select variables to the screen.
-a | --array   dump the array contents to the screen (requires -v 
option)


CHANGELOG: version 0.0.5

  - Added to -n | --notext switch to suppress output of the list to the console
  - Added the ability to (1) select packages in the zenity list for install
  - Added confirm install dialog that allows modification and confirmation of 
packages to install with pacman -Sy


TODO:

  - Perhaps add an initial searchterm or filename zenity dialog so this script 
can simply be run from a launcher on your desktop.


	Let me know if this is something that should be added to AUR or somewhere for 
people to find long after this email thread has died.


Enjoy :p

--
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


Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-10 Thread David C. Rankin

On 08/10/2010 09:31 PM, David C. Rankin wrote:

On 08/10/2010 05:29 PM, David C. Rankin wrote:

On 08/10/2010 03:46 PM, David C. Rankin wrote:

On 08/05/2010 10:51 PM, David C. Rankin wrote:

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


snip






Version 0.0.6

  - bugfix - added the command line select of only installed/uninstalled to 
zenity --list output :p


--
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


Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-07 Thread Simon Stoakley

On 06/08/10 19:40, Simon Stoakley wrote:

On 06/08/10 06:33, Dave Reisner wrote:


Hi.

Let's see what we can do about cutting back a little on the verbosity,
and upping the utility...

-

#!/bin/bash

pkg=()
desc=()
count=-1



Snip



Been messing around with this a little, added pacman -Qs option, single 
space option (-d default) and some colours. Wrapped it in a function so 
can call it pacside [-qs] schstring.

Thought I'd put it back up in case anyone's interested.

pacside() {

sidesch() {

bldblu='\e[1;34m' # Blue
bldwht='\e[1;37m' # White
txtrst='\e[0m'# Text Reset

pkg=()
desc=()
count=-1
WIDTH=${WIDTH:-70}

while read line; do
if [[ $line =~ 
^(testing|core|extra|community|community-testing|local)/* ]]; then

(( count++ ))
line=$(echo $line | echo $line |cut -d [ -f1 )
pkg[$count]=$line
  continue
fi

desc[$count]+=$line
done

i=0
while (( i = $count )); do
IFS=$'\n' read -r -d'\0' -a blockdesc  (fmt -w$WIDTH  
${desc[i]})


paste -d' ' (printf ${bldblu}\t%-60s ${pkg[i]}) (echo 
-e ${bldwht}${blockdesc[0]}${txtrst})


for line in ${blockde...@]:1}; do
printf ${bldwht}\t%-61s%s\n  $line
done

(( ++i ))
[[ $1 != -s ]]  echo
done
}

[[ -z $2 ]]  pacman -Ss $1 | sidesch
[[ $1 == -s ]]  pacman -Ss $2 | sidesch -s
[[ $1 == -q ]]  pacman -Qs $2 | sidesch
[[ $1 == -sq ]] || [[ $1 == -qs ]]  pacman -Qs $2 | sidesch -s
}

--



Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-06 Thread nigel

On Thu, Aug 05, 2010 at 10:51:45PM -0500, David C. Rankin wrote:

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



Hi,

I'm new to Arch and to the list but wanted to say thanks for posting
this up. I've found pacman a great tool for getting what I need
installed, but browsing and looking around it was tricky - this script
is really useful for that.

Thanks,
Nigel


Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-06 Thread Simon Stoakley

On 06/08/10 06:33, Dave Reisner wrote:


Hi.

Let's see what we can do about cutting back a little on the verbosity,
and upping the utility...

-

#!/bin/bash

pkg=()
desc=()
count=-1
WIDTH=${WIDTH:-50}

while read line; do
   if [[ $line =~ ^(testing|core|extra|community|community-testing)/* ]]; then
 (( count++ ))
 pkg[count]=$line
 continue
   fi

   desc[count]+=$line
done

i=0
while (( i= count )); do
   IFS=$'\n' read -r -d'\0' -a blockdesc  (fmt -w$WIDTH  ${desc[i]})

   paste -d' '(printf %-49s ${pkg[i]})(echo ${blockdesc[0]})

   for line in ${blockde...@]:1}; do
 printf %-50s%s\n  $line
   done

   (( ++i ))
   [[ $1 == -d ]]  echo
done

-

It takes STDIN, and accepts a -d option to add a space after each
package. Descriptions have a default width of 50 characters (meaning a
total width of 100 characters). You can alter this by specifying WIDTH
as an environment var, e.g.

$ pacman -Ss | WIDTH=30 ./foofilter -d

Personally I think pacman-color is a better solution that mangling the
output like this, but to each their own.

d




---
Thanks for this one, I've messed around with it a little and it's a 
handy little function for searching.


Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-06 Thread David C. Rankin

On 08/06/2010 12:09 AM, Jason Reardon wrote:

if which zenity
/dev/null..., the former doesn't redirect error output.


Thanks - updated.

--
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


Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-06 Thread fons
On Fri, Aug 06, 2010 at 05:11:27PM +0100, ni...@greenlemur.com wrote:

 On Thu, Aug 05, 2010 at 10:51:45PM -0500, David C. Rankin wrote:

 http://www.3111skyline.com/dl/Archlinux/scripts/srch2list.sh
 
 I'm new to Arch and to the list but wanted to say thanks for posting
 this up. I've found pacman a great tool for getting what I need
 installed, but browsing and looking around it was tricky - this script
 is really useful for that.

Nice. But why not read from stdin if no file is given, e.g.

   pacman -Ss ttf | srch2list.sh

-- 
FA

There are three of them, and Alleline.



Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-06 Thread David C. Rankin

On 08/06/2010 12:33 AM, Dave Reisner wrote:

Hi.

Let's see what we can do about cutting back a little on the verbosity,
and upping the utility...



Dave,

	Thanks. It will take me a bit to decipher it, but I'm all for cutting down on 
typing and upping the benefit received :p


I have a question. I was trying to figure the script out by passing in one of my 
pacman -Ss save files as follows, but I keep getting an error:


16:36 alchemy:~/scr/arch cat dev/font.pms | sh srchreisner.sh
srchreisner.sh: line 20: syntax error near unexpected token `'
srchreisner.sh: line 20: `  IFS=$'\n' read -r -d'\0' -a blockdesc  (fmt 
-w$WIDTH  ${desc[i]})'


Where in the black-magic or in my operation of it lies the problem?

--
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


Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-06 Thread David C. Rankin

On 08/06/2010 04:40 PM, David C. Rankin wrote:

On 08/06/2010 12:33 AM, Dave Reisner wrote:

Hi.

Let's see what we can do about cutting back a little on the verbosity,
and upping the utility...



Dave,

Thanks. It will take me a bit to decipher it, but I'm all for cutting down on
typing and upping the benefit received :p

I have a question. I was trying to figure the script out by passing in one of my
pacman -Ss save files as follows, but I keep getting an error:

16:36 alchemy:~/scr/arch cat dev/font.pms | sh srchreisner.sh
srchreisner.sh: line 20: syntax error near unexpected token `'
srchreisner.sh: line 20: ` IFS=$'\n' read -r -d'\0' -a blockdesc  (fmt
-w$WIDTH  ${desc[i]})'

Where in the black-magic or in my operation of it lies the problem?



Never mind, calling the script with sh was the issue (duh...)

--
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


Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-06 Thread David C. Rankin

On 08/06/2010 03:34 PM, f...@kokkinizita.net wrote:

On Fri, Aug 06, 2010 at 05:11:27PM +0100, ni...@greenlemur.com wrote:


On Thu, Aug 05, 2010 at 10:51:45PM -0500, David C. Rankin wrote:


http://www.3111skyline.com/dl/Archlinux/scripts/srch2list.sh


I'm new to Arch and to the list but wanted to say thanks for posting
this up. I've found pacman a great tool for getting what I need
installed, but browsing and looking around it was tricky - this script
is really useful for that.


Nice. But why not read from stdin if no file is given, e.g.

pacman -Ss ttf | srch2list.sh



Actually I'm working on just passing the script the search term and calling 
pacman from within the script. The problem with piping the output into the 
script is it messed up my terminal size calcs (stty doesn't like the script 
taking input from stdin) and one of the primary goals I had for the script was 
for it to dynamically size the output based on (1) the longest filename returned 
(to set column 1 width) and (2) to size the description column using the 
remainder of the terminal width leaving the 1 char margin. So keeping the 
ability to grab the terminal size from stty was key.


I'm working to learn the why's of stty seeing things as a file and not a tty 
when piping input from stdin, but I'm not there yet. I'll update the input 
routine for the script so it will be flexible enough to take a search term, a 
saved search file and/or have it prompt for the search term  or filename using 
zenity or stdin. That will get the script to where I want it to be. But knowing 
my schedule (and distractions from 3 kids) I thought I would go ahead and post 
the reformatting part so some use could be made of it until I have an hour or 
two to work out the final input.


--
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


Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-05 Thread Loui Chang
On Thu 05 Aug 2010 22:51 -0500, David C. Rankin wrote:
 Guys,

You got a script for the gals too? :D

   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
 
   or with the '-d' option for semi-doublespace:

This should definitely be the default. Otherwise I may go walleyed.

   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.

Cheers.



Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-05 Thread David C. Rankin

On 08/05/2010 10:51 PM, David C. Rankin wrote:
snip

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



OK,

	The zenity output was simpler than I thought. If you got the script before I 
added the zenity --list output, then download it again. The script is here:


http://www.3111skyline.com/dl/Archlinux/scripts/srch2list.sh

The zenity --list output looks like this:

(82k)
http://www.3111skyline.com/dl/Archlinux/scripts/srch2list-zenity.jpg

Now I can read it :p

--
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


Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-05 Thread David C. Rankin

On 08/05/2010 11:19 PM, Loui Chang wrote:

or with the '-d' option for semi-doublespace:

This should definitely be the default. Otherwise I may go walleyed.



You are correct sir! I guess the only reason it wasn't the default is that I did 
the script on my laptop so vertical space was at a premium :p


I have to rework the options anyway to add an option to disable the zenity list 
so I'll redo the line spacing default as well.


Right now I have the script testing for zenity with which and then displaying 
the zenity --list by default if zenity is installed. What's your vote? Should 
zenity be off by default and then enabled with an option?. It is light enough to 
work well even over ssh connections, so my thought was to just leave it enabled 
by default and add a flag to disable it if it wasn't wanted..


--
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


Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-05 Thread Jason Reardon
Sweet script, it always bothered me the way pacman -Ss formatted its output.
The check you do for zenity has a minor problem, though. Instead of if
which zenity  /dev/null... it needs to be if which zenity 
/dev/null..., the former doesn't redirect error output.

Anyway, very well done, thanks for the script!

Jason

On Fri, Aug 6, 2010 at 12:48 AM, David C. Rankin 
drankina...@suddenlinkmail.com wrote:

 On 08/05/2010 11:19 PM, Loui Chang wrote:

or with the '-d' option for semi-doublespace:

 This should definitely be the default. Otherwise I may go walleyed.


 You are correct sir! I guess the only reason it wasn't the default is that
 I did the script on my laptop so vertical space was at a premium :p

 I have to rework the options anyway to add an option to disable the zenity
 list so I'll redo the line spacing default as well.

 Right now I have the script testing for zenity with which and then
 displaying the zenity --list by default if zenity is installed. What's your
 vote? Should zenity be off by default and then enabled with an option?. It
 is light enough to work well even over ssh connections, so my thought was to
 just leave it enabled by default and add a flag to disable it if it wasn't
 wanted..


 --
 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



Re: [arch-general] script to reformat 'pacman -Ss' output into 2 readable columns (prevents blindness)

2010-08-05 Thread Dave Reisner
On Thu, Aug 05, 2010 at 10:51:45PM -0500, David C. Rankin wrote:
 Guys,
 
   I developed a script...

Hi.

Let's see what we can do about cutting back a little on the verbosity,
and upping the utility...

-

#!/bin/bash

pkg=()
desc=()
count=-1
WIDTH=${WIDTH:-50}

while read line; do
  if [[ $line =~ ^(testing|core|extra|community|community-testing)/* ]]; then
(( count++ ))
pkg[count]=$line
continue
  fi

  desc[count]+=$line
done

i=0
while (( i = count )); do
  IFS=$'\n' read -r -d'\0' -a blockdesc  (fmt -w$WIDTH  ${desc[i]})

  paste -d' ' (printf %-49s ${pkg[i]}) (echo ${blockdesc[0]})

  for line in ${blockde...@]:1}; do
printf %-50s%s\n  $line
  done

  (( ++i ))
  [[ $1 == -d ]]  echo
done

-

It takes STDIN, and accepts a -d option to add a space after each
package. Descriptions have a default width of 50 characters (meaning a
total width of 100 characters). You can alter this by specifying WIDTH
as an environment var, e.g.

$ pacman -Ss | WIDTH=30 ./foofilter -d

Personally I think pacman-color is a better solution that mangling the
output like this, but to each their own.

d