forked from wcaleb/se-aliases
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,55 @@ | ||
# Search Engine Aliases | ||
# by W. Caleb McDaniel, 2012 | ||
# | ||
# Free software distributed under GNU General Public License. No warranty. | ||
# | ||
# The idea for this was suggested by Lincoln Mullen's post on | ||
# configuring Chrome for specific search engines. I source this file | ||
# in my bashrc, and then use DTerm or the Terminal to quickly search. | ||
# This method makes Mullen's ideas browser-independent on the Mac. | ||
# Search engines can be tied to specific browsers using the -a flag for | ||
# the open command. For more context, see: | ||
# | ||
# http://chronicle.com/blogs/profhacker/how-to-hack-urls-for-faster-searches-in-your-browser/42304 | ||
|
||
|
||
# To prepare plain-text queries for URLs, use python. | ||
# http://ruslanspivak.com/2010/06/02/urlencode-and-urldecode-from-a-command-line/ | ||
|
||
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"' | ||
alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"' | ||
|
||
# Use these at the command line by typing the function's name and the | ||
# query. Queries with more than one word should be enclosed in double | ||
# quotes. Literal quotes can be added to queries with the escape slash. | ||
# | ||
# E.g. | ||
# | ||
# scholar abolitionists | ||
# scholar "American abolitionists" | ||
# scholar "\"American abolitionists\"" | ||
|
||
function scholar | ||
{ | ||
QUERY=$(urlencode "$1") | ||
open "http://scholar.google.com/scholar?hl=en&q=$QUERY" | ||
open "http://scholar.google.com/scholar?hl=en&q=`urlencode "$1"`" | ||
} | ||
|
||
function books | ||
{ | ||
QUERY=$(urlencode "$1") | ||
open "http://books.google.com/books?hl=en&q=$QUERY" | ||
open "http://books.google.com/books?hl=en&q=`urlencode "$1"`" | ||
} | ||
|
||
function images | ||
{ | ||
QUERY=$(urlencode "$1") | ||
open "http://images.google.com/images?q=$QUERY" | ||
open "http://images.google.com/images?q=`urlencode "$1"`" | ||
} | ||
|
||
function images | ||
{ | ||
QUERY=$(urlencode "$1") | ||
open "http://images.google.com/images?q=$QUERY" | ||
open "http://images.google.com/images?q=`urlencode "$1"`" | ||
} | ||
|
||
function amazon | ||
{ | ||
QUERY=$(urlencode "$1") | ||
open "http://www.amazon.com/s/?url=search-alias%3Daps&field-keywords=$QUERY" | ||
open "http://www.amazon.com/s/?url=search-alias%3Daps&field-keywords=`urlencode "$1"`" | ||
} | ||
|