Skip to content

Instantly share code, notes, and snippets.

@Leask
Created December 4, 2012 15:40
Show Gist options
  • Save Leask/4205276 to your computer and use it in GitHub Desktop.
Save Leask/4205276 to your computer and use it in GitHub Desktop.
Source this script then search the web!
# Flora Search by LeaskH.com
function encode() {
echo "$*" | LANG=C awk '
function char2hex(char) {
for (j = 0; j < 256; j++) {
if (sprintf("%c", j) == char) {
return sprintf("%%%X", j);
}
}
return char;
}
BEGIN {
FS = "";
OFS = "";
}
{
for (i=1; i <= NF; i++) {
$i = char2hex($i);
}
print;
}
'
}
function f() {
osascript -e "tell application \"Finder\"
activate
tell application \"System Events\"
keystroke \"f\" using command down
keystroke \"$*\"
key code 36 # press enter
key code 48 # press tab
keystroke \" \" # press space
end tell
end tell"
}
function p() {
osascript -e "tell application \"System Events\"
keystroke space using control down
delay 1
keystroke \"$*\"
end tell"
}
function www() {
open "http://$*"
}
function g() {
open "https://www.google.com/search?client=safari&rls=en&q=`encode $*`&ie=UTF-8&oe=UTF-8"
}
function gl() {
open "https://www.google.com/search?client=safari&rls=en&q=`encode $*`&ie=UTF-8&oe=UTF-8&btnI=745"
}
function gm() {
if [ "$*" = '' ]; then
key='inbox'
else
key="apps/$*"
fi
open "https://mail.google.com/mail/u/0/?shva=1#$key"
}
function yt() {
open "http://www.youtube.com/results?search_query=$*"
}
function duck() {
open "https://duckduckgo.com/?q=$*"
}
function aapl() {
open "http://www.apple.com/search/?q=$*"
}
function amzn() {
open "http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=$*"
}
function twt() {
open "https://twitter.com/search/realtime?q=$*&src=typd"
}
function fb() {
open "https://www.facebook.com/search/results.php?q=$*&init=quick&tas=search_preload"
}
function dban() {
open "http://www.douban.com/search?q=$*"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment