You are not logged in.

#1 2006-11-17 10:32:02

Firmicus
Forum Fellow
From: Germany
Registered: 2006-02-28
Posts: 168

pacurl: simple script to open URL of package in browser

This is a very simple bash script that I use when I need to visit the official webpage of some package, e.g. to consult online doc (especially useful in Arch since we only have manpages) or submit a bug report. I call this little script pacurl.

#!/bin/bash

url=`pacman -Qi $1 | egrep ^URL | cut -c18-`
[ ! "x$url" == "x"  ] && firefox $url

Example: pacurl sed opens the page http://www.gnu.org/software/sed/ in firefox.

If you rather want to open the URL that pertains to some binary instead then you can modifiy the above thus:

#!/bin/bash

path=`which $1`
pkg=`pacman -Qo $path | cut -d' ' -f5`
url=`pacman -Qi $pkg | egrep ^URL | cut -c18-`
[ ! "x$url" == "x"  ] && firefox $url

Example: If you name the above script, say, "urlof", then urlof watch will open http://procps.sourceforge.net/

Hope it is useful

Offline

#2 2006-11-27 08:42:20

Ibex
Member
Registered: 2006-03-02
Posts: 135

Re: pacurl: simple script to open URL of package in browser

Or, to open the url in a new tab in your running firefox:

// change
//   [ ! "x$url" == "x"  ] && firefox $url
// to

[ ! "x$url" == "x"  ] && firefox --remote "openurl( $url ,new-tab)"

Offline

#3 2006-11-27 14:33:26

Phrodo_00
Member
From: Seattle, WA
Registered: 2006-04-09
Posts: 342
Website

Re: pacurl: simple script to open URL of package in browser

Ibex wrote:

Or, to open the url in a new tab in your running firefox:

// change
//   [ ! "x$url" == "x"  ] && firefox $url
// to

[ ! "x$url" == "x"  ] && firefox --remote "openurl( $url ,new-tab)"

if I remember well (I probably don't), -t also opens a new tab on the most recent window...

Offline

#4 2007-04-02 10:26:14

Firmicus
Forum Fellow
From: Germany
Registered: 2006-02-28
Posts: 168

Re: pacurl: simple script to open URL of package in browser

Improvement to open the URL of uninstalled packages as well. It assumes you have an up-to-date ABS tree under /var/abs.

#!/bin/bash

url=`pacman -Qi $1 2> /dev/null | egrep ^URL | cut -c18-`
if [ "x$url" == "x"  ] ; then
    echo "Package $1 is not installed. Searching in /var/abs ..."
    tmpurl=`mktemp`
    find /var/abs -wholename "*/$1/PKGBUILD" -exec egrep ^url '{}' \; > $tmpurl
    source $tmpurl
    rm $tmpurl
fi
        
if [ ! "x$url" == "x"  ] ; then 
    firefox --remote "openurl( $url ,new-tab)
else
    echo "Not found. Perhaps it is in AUR?"
fi

To search in AUR as well you can change the last three lines by :

else
    echo "Not found. Searching in AUR..."
    tmpurlaur=`mktemp`
    wget -c -q http://aur.archlinux.org/packages/$1/$1/PKGBUILD | egrep ^url > $tmpurlaur 
    source $tmpurlaur
    rm $tmpurlaur
    if [ ! "x$url" == "x"  ] ; then 
        firefox --remote "openurl( $url ,new-tab)
    else
        echo "package $1 found neither in repos nor in AUR"
    fi
fi

Offline

#5 2007-04-02 11:06:28

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: pacurl: simple script to open URL of package in browser

A note on the AUR search - the use of URLs of that sort is not recommended, as it is possible to return PKGBUILDs for packages that have been deleted from the AUR.

Any tool that accesses the AUR by any means other than the website has to take this into account. Check the aurbuild/yaourt/etc code for other ways to do this.

Offline

#6 2007-04-02 11:14:42

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: pacurl: simple script to open URL of package in browser

I wondered if something like this could be added to pacman tbh.  I was thinking about it a while ago.  Nice idea smile

Offline

Board footer

Powered by FluxBB