shortcutwiki

Submitted scripts and programs
Forum rules
Your own work only.
machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

shortcutwiki

Unread post by machinebacon » Tue Jul 01, 2014 5:46 am

Even in an X session I like to quickly access articles on wikipedia using a CLI browser (links, links2, netrik, w3m, lynx). I assigned Alt-F5 to open x-terminal-emulator -e shortcutwiki, which is nothing else than a TUI asking for user input before entering the CLI browser. Requires perl, dialog and a browser ;)

Code: Select all

#!/bin/bash
. /usr/share/doc/dialog/examples/setup-vars
. /usr/share/doc/dialog/examples/setup-tempfile

# set your browser here 
BROWSER=links

encode() { 
	echo -n $@ | perl -pe's/([^-_.~A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg'; 
}

wikien() { 
	$BROWSER http://en.wikipedia.org/w/index.php?search="`encode $@`" ;
}

$DIALOG --nocancel --title "EN.WIKIPEDIA.ORG" --clear "$@" \
        --inputbox "Look up article:" 0 0 2> $tempfile

wikien `cat $tempfile`
..gnutella..

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

Re: shortcutwiki

Unread post by machinebacon » Tue Jul 01, 2014 5:48 am

Germanic version o/

Code: Select all

#!/bin/bash
. /usr/share/doc/dialog/examples/setup-vars
. /usr/share/doc/dialog/examples/setup-tempfile

# set your browser here 
BROWSER=links

encode() { 
	echo -n $@ | perl -pe's/([^-_.~A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg'; 
}

wikide() { 
	$BROWSER http://de.wikipedia.org/w/index.php?search="`encode $@`" ;
}

$DIALOG --nocancel --title "DE.WIKIPEDIA.ORG" --clear "$@" \
        --inputbox "Artikel nachschlagen:" 0 0 2> $tempfile

wikide `cat $tempfile`
..gnutella..

Post Reply