You are not logged in.

#1 2012-02-19 12:57:42

cryptkeeper
Member
From: Zurich, Switzerland
Registered: 2011-12-29
Posts: 63

[SOLVED] `pacman -Ss`: change list format

I don't like the list format of `pacman -Ss`. It's a pain to go through long search reslt lists because only every second line contains a package name and the package desctiption is on the next line. I'd prefer a format with one line per package, i.e. the name on the left and the description on the same line, not on the next line. That would make scanning through long lists much easier.

Is there a way to configure pacman like this?

Last edited by cryptkeeper (2012-02-19 13:50:56)

Offline

#2 2012-02-19 13:04:40

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,465
Website

Re: [SOLVED] `pacman -Ss`: change list format

I'm not sure how to change pacman's behavior, but you can make a script or bash function to do this

pacman -Ss "$@" | while read line; do echo -n "$line"; read line; echo -e "\t$line"; done

I just made this up, so I'm sure it could be tweaked to look better, but this is the meat of it to do what you want.

Edit: better and easier to tweak:

 pacman -Ss "$@" | while read package; do read description; echo -e "$package\t$description"; done

Last edited by Trilby (2012-02-19 13:09:59)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2012-02-19 13:20:05

cryptkeeper
Member
From: Zurich, Switzerland
Registered: 2011-12-29
Posts: 63

Re: [SOLVED] `pacman -Ss`: change list format

Thanks for your fast answer, the command does just what I want. I already considered writing a short script for the task, but though I first ask if the output format could simply be changed in a config file. As this doesn't seem to be the case, I'll write a script based on your command refining the output a bit.

Edit: I made a short script. Basically it's just you're command, but I added the feature that lines that are too long to be displayed in the terminal window are cut off.

#!/bin/bash
#
# paclist - `pacman -Ss` wrapper
#

pacman -Ss "$@" | while read package
do
   read description
   line="$package - $description"
   columns=`tput cols`
   if [[ ${#line} -gt $((columns-3)) ]]
   then
      line="${line:0:$columns-3}..."
   fi
   echo -e "$line"
done

Last edited by cryptkeeper (2012-02-19 13:49:27)

Offline

#4 2012-02-19 14:49:48

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: [SOLVED] `pacman -Ss`: change list format

Look at expac if you want custom formatted output.

Offline

#5 2012-02-20 11:08:02

cryptkeeper
Member
From: Zurich, Switzerland
Registered: 2011-12-29
Posts: 63

Re: [SOLVED] `pacman -Ss`: change list format

Thanks for the tip, I'll keep expac in mind. For now though, I just stick to the script as a quick-and-dirty solution.

Offline

Board footer

Powered by FluxBB