local elvi

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

local elvi

Unread post by machinebacon » Sat Jul 19, 2014 1:03 pm

For all surfraw users, here's a local elvi to search the linuxbbq wiki using sr:

1) mkdir -p ~/.config/surfraw/elvi
2) $EDITOR ~/.config/surfraw/elvi/bbq

Code: Select all

#!/bin/sh
# elvis: bbq    -- Search the LinuxBBQ Wiki
# Author: machinebacon

. surfraw || exit 1

w3_config_hook () {
def   SURFRAW_linuxbbq_language "$SURFRAW_lang"
}

w3_usage_hook () {
    cat <<EOF
Usage: $w3_argv0 [options] [search-string]
Description:
  Search the LinuxBBQ Wiki (linuxbbq.org/wiki)

Local options
 -language=ISOCODE              Two letter language code (resembles ISO country codes)
 -l=ISOCODE
           en           |       Main LinuxBBQ Wiki site (default)
                                Environment: SURFRAW_linuxbbq_language, SURFRAW_lang
                                Default: en
EOF
    w3_global_usage
}

w3_parse_option_hook () {
    opt="$1"
    optarg="$2"
    case "$opt" in
        -language=*)    setopt  SURFRAW_linuxbbq_language       $optarg ;;
        -l=*)                   setopt  SURFRAW_linuxbbq_language       $optarg ;;
        *) return 1 ;;
    esac
    return 0
}
w3_config
w3_parse_args "$@"
# w3_args now contains list of arguments

case "$SURFRAW_linuxbbq_language" in
    en) domain=".org"           ;;
     *) domain=".org"           ;;
esac        

protocol="http://";

if [ -z "$w3_args" ]; then
    w3_browse_url "${protocol}linuxbbq${domain}/"
else
    escaped_args=$(w3_url_of_arg $w3_args)
    w3_browse_url "${protocol}linuxbbq${domain}/wiki/index.php?search=${escaped_args}"
fi
check if it's in the list:

Code: Select all

sr -elvi
use it:

Code: Select all

sr bbq BBQ philosophy
sr bbq Jwm
sr bbq Fishy
sr bbq Rotten Meat
# search term capitalized!
..gnutella..

Post Reply