Skip to content

Instantly share code, notes, and snippets.

@ahtn
Created June 30, 2017 22:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahtn/4b0d033b9baa8d936accc2cf2465d168 to your computer and use it in GitHub Desktop.
Save ahtn/4b0d033b9baa8d936accc2cf2465d168 to your computer and use it in GitHub Desktop.
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