Jason Ryan avatar Jason Ryan committed b6f1985

Initial commit of surfraw files

Comments (0)

Files changed (9)

.config/surfraw/bookmarks

+# Bookmarked urls for Surfraw
+fe	https://wiki.archlinux.org/index.php/Forum_Etiquette
+git	http://git.debian.org/?p=surfraw/surfraw.git;a=tree
+sr  http://alioth.debian.org/projects/surfraw/
+

.config/surfraw/conf

+# Surfraw -- Shell Users' Revolutionary Front Against the World wide web
+SURFRAW_text_browser=/usr/bin/w3m
+SURFRAW_graphical=0
+SURFRAW_screen=tmux
+SURFRAW_new_screen=no
+

.config/surfraw/elvi/archpkg

+#!/bin/sh
+# elvis: archpkg		-- Search Arch Linux Packages (www.archlinux.org/packages/)
+# Author: jason ryan • http://jasonwryan.com
+
+. surfraw || exit 1
+
+w3_config_hook () {
+def   SURFRAW_arch_ix           "$SURFRAW_ix"
+def   SURFRAW_arch_repo         "$SURFRAW_repo"
+def   SURFRAW_arch_date         "$SURFRAW_date"
+def   SURFRAW_arch_results       25	
+}
+
+w3_usage_hook () {
+    cat <<EOF
+Usage: $w3_argv0 [options] [search string]
+Description: Surfraw search Arch Linux packages (www.archlinux.org)
+
+	Local options:
+      -arch=ARCHITECTURES  | -a=ARCHITECTURES
+		any        |   Any (default)
+		i686       |   i686
+		x86_64     |   x86_64
+
+       -repo=REPOSITORIES  | -r=REPOSITORIES
+		comm       |   Community
+		commtest   |   Community-Testing
+		core       |   Core
+		extra      |   Extra
+		multi      |   Multilib
+		multitest  |   Multilib-Testing
+		test       |   Testing
+		               Default: All
+
+	-date=UPDATED  | -d=UPDATED (format: YYYY-MM-DD)
+
+	-num=NUMBER    |  Number of results per page
+	                  Default: $SURFRAW_arch_results
+
+EOF
+    w3_global_usage
+}
+
+w3_parse_option_hook () {
+    opt="$1"
+    optarg="$2"
+    case "$opt" in
+	-a*=*)	setopt   SURFRAW_arch_ix        $optarg ;;
+	-r*=*)	setopt   SURFRAW_arch_repo      $optarg ;;
+	-d*=*)	setopt   SURFRAW_arch_date      $optarg ;;
+	-n*=*)	setopt   SURFRAW_arch_results   $optarg ;;
+	    *)	return 1 ;;
+    esac
+    return 0
+}
+
+w3_config
+w3_parse_args "$@"
+
+# selected repository
+case "$SURFRAW_arch_repo" in
+	comm)     repo="Community"         ;;
+	commtest) repo="Community-Testing" ;;
+	core)     repo="Core"              ;;
+	extra)    repo="Extra"             ;;
+	multi)    repo="Multilib"          ;;
+	multitest)repo="Multilib-Testing"  ;;
+	test)     repo="Testing"           ;;
+	*)        repo=""                  ;;
+esac
+
+# no arguments present
+if [ -z "$w3_args" ]; then
+    w3_browse_url "http://www.archlinux.org/packages/"
+
+else
+# if w3_args contains a list of arguments
+escaped_args=$(w3_url_of_arg $w3_args)
+base="http://www.archlinux.org/packages/?sort="
+
+	# repository and architecture
+	if [ -n "$SURFRAW_arch_repo" -a "$SURFRAW_arch_ix" ]; then
+	w3_browse_url "${base}&arch=${SURFRAW_arch_ix}&repo=${repo}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}"
+	
+	# check for repository
+	elif [ -n "$SURFRAW_arch_repo" ]; then
+	w3_browse_url "${base}&repo=${repo}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}"
+
+	# just architecture
+	elif [ -n "$SURFRAW_arch_ix" ]; then
+	w3_browse_url "${base}&arch=${SURFRAW_arch_ix}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}"
+
+	# none of the above...
+	else
+	w3_browse_url "${base}&q=${escaped_args}&maintainer=&last_update=${SURFRAW_arch_date}&flagged=&limit=${SURFRAW_arch_results}"
+	fi
+fi
+

.config/surfraw/elvi/archwiki

+#!/bin/bash
+# elvis: archwiki	-- Search the Arch Linux Wiki (http://wiki.archlinux.org)
+# Author: jason ryan • http://jasonwryan.com
+
+. surfraw || exit 1
+
+w3_config_hook () {
+def   SURFRAW_archwiki_language	"$SURFRAW_lang"
+}
+
+w3_usage_hook () {
+    cat <<EOF
+Usage: $w3_argv0 [options] [search-string]
+Description:
+  Search the Arch Linux Wiki (wiki.archlinux.org)
+
+Local options
+ -language=ISOCODE | -l=ISOCODE  Two letter language code (resembles ISO country codes)
+           en	|   Main Arch Wiki site (default)
+           fr	|   French
+           de	|   German
+           he	|   Hebrew
+           pl	|   Polish
+           pt	|   Portugese
+           ro	|   Romanian
+           es	|   Spanish
+           sv	|   Swedish
+           uk	|   Ukranian
+
+                    Default: en
+
+EOF
+    w3_global_usage
+}
+
+w3_parse_option_hook () {
+    opt="$1"
+    optarg="$2"
+    case "$opt" in
+	-language=*)  setopt  SURFRAW_archwiki_language	$optarg	;;
+	-l=*)         setopt  SURFRAW_archwiki_language	$optarg	;;
+	*) return 1 ;;
+    esac
+    return 0
+}
+w3_config
+w3_parse_args "$@"
+# w3_args now contains list of arguments
+
+case "$SURFRAW_archwiki_language" in
+    en) domain=".org"    ;;
+    fr) domain=".fr"     ;;
+    de) domain=".de"     ;;
+    he) domain=".il"     ;;
+    pl) domain=".pl"     ;;
+    pt) domain="-br.org" ;;
+    ro) domain=".ro"     ;;
+    es) domain=".cl"     ;;
+    sv) domain=".sv"     ;;
+    uk) domain=".ua"     ;;
+     *) domain=".org"    ;;
+esac
+
+# handle ssl
+if [ $domain = ".org" -o $domain = ".de" ]; then
+	protocol="https://";
+  else	
+	protocol="http://";
+fi
+
+if [ -z "$w3_args" ]; then
+    w3_browse_url "${protocol}wiki.archlinux${domain}/"
+  else
+    escaped_args=$(w3_url_of_arg $w3_args)
+    w3_browse_url "${protocol}wiki.archlinux${domain}/index.php?search=${escaped_args}"
+fi
+

.config/surfraw/elvi/deli

+#!/bin/sh
+# elvis: deli		-- Search Delicious bookmarks
+# Author: jason ryan • http://jasonwryan.com
+
+. surfraw || exit 1
+
+w3_config_hook () {
+def   SURFRAW_delicious_results $SURFRAW_results
+def   SURFRAW_delicious_tags $SURFRAW_tags
+def   SURFRAW_delicious_user $SURFRAW_user
+}
+
+w3_usage_hook () {
+    cat <<EOF
+Usage: $w3_argv0 [options] [search-string]
+Description: Search Delicious bookmarks (www.delicious.com)
+
+Local options
+ -tags=TAG  | -t=TAG            Refine your search with tags
+                                [Separate multiple tags with "+"]
+
+ -user=USER | -u=USER           Search a particular user's bookmarks
+
+EOF
+    w3_global_usage
+}
+
+w3_parse_option_hook () {
+    opt="$1"
+    optarg="$2"
+    case "$opt" in
+        -t*=*)     setopt	SURFRAW_delicious_tags	$optarg  ;;
+        -u*=*)     setopt	SURFRAW_delicious_user	$optarg  ;;
+            *)     return 1 ;;
+    esac
+    return 0
+}
+w3_config
+w3_parse_args "$@"
+# w3_args now contains list of arguments
+
+# standard topic seach
+if [ -z "$w3_args" ]; then
+	w3_browse_url "http://www.delicious.com/search?p=${SURFRAW_delicious_results}"
+else
+	escaped_args=$(w3_url_of_arg $w3_args)
+
+	# search for topic in a user's bookmarks
+	if [ -n "${SURFRAW_delicious_user}" ]; then
+	w3_browse_url "http://www.delicious.com/${SURFRAW_delicious_user}/${escaped_args}"
+
+	# search for topic with tag(s)
+	else
+	w3_browse_url "http://www.delicious.com/tag/${escaped_args}"
+	fi
+fi

.config/surfraw/elvi/github

+#!/bin/sh
+# elvis: github		-- Search GitHub (https://github.com)
+# Author: jason ryan • https://jasonwryan.com
+
+. surfraw || exit 1
+
+w3_config_hook () {
+def   SURFRAW_git_type        "$SURFRAW_type"
+def   SURFRAW_git_lang         any 
+}
+
+w3_usage_hook () {
+    cat <<EOF
+
+Usage: $w3_argv0 [options] [search-string]
+Description: 
+	Search Github (https://github.com)
+
+	Local options:
+	-l=LANGUAGE   |  -lang=LANGUAGE
+	Languages are case sensitive, eg., C, Shell, Python etc.	 
+	Languages with spaces must be conjoined with a "+", eg, Common+Lisp
+	Default: Any
+
+	-type=SEARCH  | -t=SEARCH
+	every  |   Everything 
+	repo   |   Repositories
+	user   |   Users
+	code   |   Code
+	           Default: Everything
+
+EOF
+    w3_global_usage
+}
+
+w3_parse_option_hook () {
+    opt="$1"
+    optarg="$2"
+    case "$opt" in
+	-t*=*)       setopt   SURFRAW_git_type   $optarg ;;
+	-l*=*)       setopt   SURFRAW_git_lang   $optarg ;;
+	*) return 1 ;;
+    esac
+    return 0
+}
+w3_config
+w3_parse_args "$@"
+# w3_args now contains list of arguments
+
+# type of search selected
+case "$SURFRAW_git_type" in
+	every)  type="Everything"    	;;
+	repo)   type="Repositories"  	;;
+	user)   type="Users"         	;;
+	code)   type="Code"          	;;
+	*)      type="Everything"    	;;
+esac
+
+# No arguments parsed
+if [ -z "$w3_args" ]; then
+	w3_browse_url "https://github.com"
+else
+	# Language and/or search type selected
+	escaped_args=$(w3_url_of_arg $w3_args)
+	w3_browse_url "https://github.com/search?q=${escaped_args}&repo=&langOverride=&start_value=1&type=${type}&language=${SURFRAW_git_lang}"
+fi
+

.config/surfraw/elvi/pin

+#!/bin/sh
+# elvis: pin		-- Search Pinboard bookmarks (http://pinboard.in)
+# author: jason ryan • http://jasonwryan.com
+
+. surfraw || exit 1
+
+w3_config_hook () {
+def    SURFRAW_pinboard_tags "$SURFRAW_tags"
+def    SURFRAW_pinboard_user "$SURFRAW_user"
+def    SURFRAW_pinboard_new               0
+def    SURFRAW_pinboard_popular           0
+}
+
+w3_usage_hook () {
+    cat <<EOF
+Usage: $w3_argv0 [options] [search words]...
+Description:
+    Surfraw search Pinboard bookmarks (http://pinboard.in)
+
+    Local options:
+    Default search (without any options) includes tags, titles and descriptions 
+    and is not limited to a specific number of search terms.
+
+    -popular    |  -p  Search popular tags
+    -recent     |  -r  Search recent tags
+
+    -tags=TAGS  |  -t=TAGS  Only search tags (separate a maximum of 3 TAGS with 
+                   a "+" eg., unix+linux)
+    -user=NAME  |  -u=NAME  Search a user's bookmarks
+                    
+                                       
+EOF
+    w3_global_usage
+}
+
+w3_parse_option_hook () {
+    opt="$1"
+    optarg="$2"
+    case "$opt" in
+    -p* ) setoptyn SURFRAW_pinboard_popular 1        ;;
+    -r* ) setoptyn SURFRAW_pinboard_new     1        ;;
+    -t=*) setopt   SURFRAW_pinboard_tags    $optarg  ;;
+    -u=*) setopt   SURFRAW_pinboard_user    $optarg  ;;
+       *) return 1  ;;
+    esac
+    return 0
+}
+
+# create tag string
+tags () {    
+    local IFS=+
+
+    for tag in $SURFRAW_pinboard_tags; do
+        printf "%s" "t:$tag/"
+    done
+}
+
+
+w3_config
+w3_parse_args "$@"
+
+# w3_args now contains a list of arguments
+escaped_args=$(w3_url_of_arg $w3_args)
+base_url="https://pinboard.in/"
+
+# check for recent & popular
+if [ "$SURFRAW_pinboard_new" = 1 ]; then
+	suffix="recent/"
+elif [ "$SURFRAW_pinboard_popular" = 1 ]; then
+	suffix="popular"
+fi
+
+# Run through the other possibilities...
+if [ -z "$w3_args" ]; then  
+    
+    if [ -n "$SURFRAW_pinboard_user" ] && [ -n "$SURFRAW_pinboard_tags" ]; then
+        w3_browse_url "${base_url}u:$SURFRAW_pinboard_user/$(tags)"
+
+    elif [ -n "$SURFRAW_pinboard_tags" ]; then
+        w3_browse_url "${base_url}$(tags)"
+
+    elif [ -n "$SURFRAW_pinboard_user" ]; then
+        w3_browse_url "${base_url}u:$SURFRAW_pinboard_user"
+
+    else w3_browse_url "$base_url${suffix}"
+    fi
+
+elif [ -n "$w3_args" ]; then
+    w3_browse_url "${base_url}search/?query=${escaped_args}&all=Search+All"
+
+else
+    w3_browse_url "${base_url}"
+fi

.config/surfraw/elvi/piratebay

+#!/bin/sh
+# elvis: piratebay		-- Search The Pirate Bay (http://thepiratebay.org)
+# Author: jason ryan • http://jasonwryan.com
+
+. surfraw || exit 1
+
+w3_config_hook () {
+def   SURFRAW_bay_categories  "$SURFRAW_categories"
+}
+
+
+w3_usage_hook () {
+    cat <<EOF
+
+Usage: $w3_argv0 [options] [search words]...
+Description:
+  Search thepiratebay.org for torrents
+
+ -sort=CATEGORIES | -s=CATEGORIES
+
+  Local options:
+	all       | search all categories (default)
+	apps      | search applications
+	games     | search games
+	music     | search music
+	tv        | search TV shows
+	movies    | search movies
+                   Default: All
+
+	Subcategories:
+	flac      | flac audio files
+	books     | audio books
+	
+	dvd       | DVD rips
+	hrm       | High-res movies
+	hrt       | High-res TV
+
+EOF
+    w3_global_usage
+}
+
+w3_parse_option_hook () {
+    opt="$1"
+    optarg="$2"
+    case "$opt" in
+	-s*=*)   setopt   SURFRAW_bay_categories   $optarg ;;
+	*) return 1 ;;
+    esac
+    return 0
+}
+
+w3_config
+w3_parse_args "$@"
+
+case "$SURFRAW_bay_categories" in
+	al*)	category="0"    ;;
+	ap*)	category="300"  ;;
+	ga*)	category="400"  ;;
+	mu*)	category="100"  ;;
+	tv*)	category="205"  ;;
+	mo*)	category="201"  ;;
+	fl*)	category="104"  ;;
+	bo*)	category="102"  ;;
+	dv*)	category="202"  ;;
+	hrm)	category="207"  ;;
+	hrt)	category="208"  ;;
+	*)      category="0"    ;;
+esac
+
+# w3_args now contains a list of arguments
+escaped_args=$(w3_url_of_arg $w3_args)
+
+# just browsing category
+if [ -n "$SURFRAW_bay_categories" ] && [ -z "$w3_args" ]; then
+	w3_browse_url "http://thepiratebay.org/browse/${category}"
+
+	# searching category for string
+	elif [ -n "$SURFRAW_bay_categories" ] && [ -n "$w3_args" ]; then
+		w3_browse_url "http://thepiratebay.org/search/${escaped_args}/0/99/${category}"
+	
+	# no arguments passed
+	elif [ -z "$w3_args" ]; then
+    	w3_browse_url "http://thepiratebay.org/"
+	
+# no category specified
+else w3_browse_url "http://thepiratebay.org/search/${escaped_args}"
+		
+fi
+

.config/surfraw/elvi/stack

+#!/bin/sh
+# elvis: stack		-- Search Stack Overflow (http://stackoverflow.com)
+# Author: jason ryan • http://jasonwryan.com
+
+. surfraw || exit 1
+
+w3_config_hook () {
+def   SURFRAW_stack_categories  "$SURFRAW_categories"
+def   SURFRAW_stack_unix         0	
+def   SURFRAW_stack_results      25	
+}
+
+w3_usage_hook () {
+    cat <<EOF
+
+Usage: $w3_argv0 [options] [search-string]
+Description: 
+	Search Stack Overflow (http://stackoverflow.com)
+	Combine search terms (tags) with a "+" eg., "bash+script"
+
+	Local options:
+	-sort=CATEGORIES  | -s=CATEGORIES
+	new    |   Most recently asked (default)
+	feat   |   Questions with open bounties
+	vote   |   Questions with most votes
+	active |   Recently active
+	null   |   No upvoted answers
+	faq    |   Questions with the most links
+	           Default: new
+
+	-u     |   Search Unix & Linux Exchange
+	           Default: no
+
+	-num=NUMBER  |  Number of results per page
+	                Default: $SURFRAW_stack_results
+
+EOF
+    w3_global_usage
+}
+
+w3_parse_option_hook () {
+    opt="$1"
+    optarg="$2"
+    case "$opt" in
+	-sort=*)    setopt   SURFRAW_stack_categories   $optarg ;;
+	-s=*)       setopt   SURFRAW_stack_categories   $optarg ;;
+	-num=*)     setopt   SURFRAW_stack_results      $optarg ;;
+	-u)         setoptyn SURFRAW_stack_unix         1       ;;
+	*) return 1 ;;
+    esac
+    return 0
+}
+w3_config
+w3_parse_args "$@"
+# w3_args now contains list of arguments
+case "$SURFRAW_stack_categories" in
+	new)    category="newest"     	;;
+	feat)   category="featured"   	;;
+	vote)   category="votes"      	;;
+	active) category="active"     	;;
+	null)   category="unanswered" 	;;
+	faq)    category="faq"        	;;
+	*)      category="newest"     	;;
+esac
+
+# Check for Unix & Linux Exchange
+if [ "$SURFRAW_stack_unix" = 1 ]; then
+	url="http://unix.stackexchange.com"
+else
+	url="http://stackoverflow.com"
+fi
+
+# No arguments passed
+if [ -z "$w3_args" ]; then
+    w3_browse_url "$url"
+else
+    escaped_args=$(w3_url_of_arg $w3_args)
+	if [ -n "$SURFRAW_stack_categories" ]; then
+	w3_browse_url "${url}/questions/tagged/${escaped_args}?sort=${category}&pagesize=${SURFRAW_stack_results}"
+	else
+	w3_browse_url "${url}/questions/tagged/${escaped_args}"
+	fi
+fi
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.