Skip to content

Instantly share code, notes, and snippets.

@ahtn
Created Jun 30, 2017
Embed
What would you like to do?
Bash and Autohotkey scripts to google search highlighted text
; This Autohotkey script does a google search on the highlighted-text
SendMode Input
RegRead, OutputVar, HKEY_CLASSES_ROOT, http\shell\open\command
StringReplace, OutputVar, OutputVar,"
SplitPath, OutputVar,,OutDir,,OutNameNoExt, OutDrive
browser=%OutDir%\%OutNameNoExt%.exe
!^s::
{
BlockInput, on
prevClipboard = %clipboard%
clipboard =
Send, ^c
BlockInput, off
ClipWait, 2
if ErrorLevel = 0
{
searchQuery=%clipboard%
GoSub, GoogleSearch
}
clipboard = %prevClipboard%
return
}
GoogleSearch:
Run, %browser% "http://www.google.com/search?q=%searchQuery%"
return
#!/bin/bash
# Google search the highlighted text (requires: xdg-utils, xsel)
xdg-open "https://google.com/search?q=$(xsel)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment