• Home
  • Docs
  • About
  • Resume
  • Services
    • Testimonials
  • Contact
Humbug
Bah! Humbug!
Home 2010 Terminator Patched to Support Google Search Through Right Click Menu

Terminator Patched to Support Google Search Through Right Click Menu

  • 1 Comment
  • Tweet
Pratik Sinha | May 16, 2010

Besides xterm which is my all time favourite terminal app, Terminator is the other terminal app that I use on an everyday basis. I do a lot of coding and compiling in Terminator using vim. Its been an annoyance ever since I started using Linux (which is about 10 years now), that everytime I have to google an error, there’s no way of doing it in one singe step from any existing terminal app. Today I had an especially rough day with compilation errors and the repeated copy/pasting into google irritated the hell out me. Thats when I decided to add this support to Terminator knowing that its a python app and should be relatively simple to modify. It was infact quite easy to add the support and you can see the result of the effort below.
terminator-google-search

The deb package with google search support can be downloaded from here.

This has been compiled on Ubuntu Lucid and the base version of terminator is 0.93.

The patch for terminator 0.93 to support the Google Search feature is pasted below.

diff -urNBp terminator-0.93/terminatorlib/terminal_popup_menu.py /home/pratik/work/terminator-0.93/terminatorlib/terminal_popup_menu.py
--- terminator-0.93/terminatorlib/terminal_popup_menu.py  2010-04-16 03:16:18.000000000 +0700
+++ /home/pratik/work/terminator-0.93/terminatorlib/terminal_popup_menu.py  2010-05-17 03:06:10.000000000 +0700
@@ -4,6 +4,7 @@
 """terminal_popup_menu.py - classes necessary to provide a terminal context
 menu"""

+import pygtk
 import gtk

 from version import APP_NAME
@@ -33,6 +34,7 @@ class TerminalPopupMenu(object):
         url = None
         button = None
         time = None
+        text = None

         if event:
             url = terminal.check_for_url(event)
@@ -77,6 +79,26 @@ class TerminalPopupMenu(object):
         menu.append(item)

         menu.append(gtk.MenuItem())
+        
+        
+        google_with_quotes = 'Google Selected Text in Quotes'
+        icon = gtk.image_new_from_stock(gtk.STOCK_JUMP_TO,
+                                            gtk.ICON_SIZE_MENU)
+        item = gtk.ImageMenuItem(google_with_quotes)
+        item.connect('activate', lambda x: terminal.open_google_quoted(text, True))
+        item.set_sensitive(terminal.vte.get_has_selection())
+        menu.append(item)
+        
+        clipboard = gtk.clipboard_get()
+        text = clipboard.wait_for_text()
+        google_without_quotes = 'Google Selected Text'
+        icon = gtk.image_new_from_stock(gtk.STOCK_JUMP_TO,
+                                            gtk.ICON_SIZE_MENU)
+        item = gtk.ImageMenuItem(google_without_quotes)
+        item.connect('activate', lambda x: terminal.open_google(text, True))
+        item.set_sensitive(terminal.vte.get_has_selection())
+        menu.append(item)
+        menu.append(gtk.MenuItem())

         if not terminal.is_zoomed():
             item = gtk.ImageMenuItem('Split H_orizontally')
diff -urNBp terminator-0.93/terminatorlib/terminal.py /home/pratik/work/terminator-0.93/terminatorlib/terminal.py
--- terminator-0.93/terminatorlib/terminal.py 2010-04-16 03:16:18.000000000 +0700
+++ /home/pratik/work/terminator-0.93/terminatorlib/terminal.py 2010-05-17 03:06:10.000000000 +0700
@@ -1202,6 +1202,22 @@ for %s (%s)' % (name, urlplugin.__class_
                 import webbrowser
                 webbrowser.open(url)

+    def open_google(self, text, prepare=False):
+     """Open a given URL, conditionally unpacking it from a VTE match"""
+     url = "http://www.google.com/search?hl=en&q=" + text
+     print "URL %s" %(url)
+     print "TEXT %s" %(text)
+        import webbrowser
+        webbrowser.open(url)
+
+    def open_google_quoted(self, text, prepare=False):
+     """Open a given URL, conditionally unpacking it from a VTE match"""
+     url = "http://www.google.com/search?hl=en&q=" + '\"' + text + '\"'
+     print "URL %s" %(url)
+     print "TEXT %s" %(text)
+     import webbrowser
+     webbrowser.open(url)
+
     def paste_clipboard(self, primary=False):
         """Paste one of the two clipboards"""
         for term in self.terminator.get_target_terms(self):

The next step is to assign keyboard shortcuts to “Google Selected Text” and “Google Selected Text with Quotes” so that the invocation can be faster.

Posted in Code-Snippets | Tagged annoyance, google search, terminator | 1 Response

  • Tweet
Logging In...

Profile cancel

Sign in with Twitter Sign in with Facebook
or

Not published

 

  • 1 Reply
  • 0 Comments
  • 0 Tweets
  • 0 Facebook
  • 1 Pingback
Last reply was 733 days ago
  1. Tweets that mention Terminator Patched to Support Google Search Through Right Click Menu | Humbug -- Topsy.com
    View 733 days ago

    [...] This post was mentioned on Twitter by Pratik Sinha. Pratik Sinha said: Terminator Patched to Support Google Search Through Right Click Menu http://humbug.in/z/17 #terminator #annoyance #fb #in [...]

    Reply
« Previous Next »

Search

Recommend on Google
  • RSS
Follow @free_thinker

Get the latest posts delivered straight to your inbox.

Categories

  • Bookmarks
  • Code-Snippets
  • Guides
  • Info
  • Software
  • Testimonials
  • Tips-N-Tricks
  • Updates

Recently Popular

  • Make English the Default Language for Google Chrome Search
  • Parse Simple XML Files using Bash – Extract Name Value Pairs and Attributes
  • Kill/Quit and Restart Plasma on KDE
  • Bash Tricks: Split / Cut a String with Multi Character Delimiters
  • Enable SPDY in Firefox 11 on Ubuntu 12.04 beta
  • Utility to Send Commands or Data to Other Terminals (tty/pts)
  • A Sample Loop in XSL, Alternative for While, For Loops
  • Bash Tricks: Create variables dynamically using some eval magic
  • Kickstrap – CSS Framework: Enhancements for Bootstrap
  • WordPress Plugin: Cleaner WordPress Editor – Trying To Make WordPress Editing a Pleasure

Latest Tweets

  • 2 unexploded bombs found under Ho Chi Minh City house - Approximately 800,000 tons of bombs and mines still present humbug.in/z/9i #fb 4 weeks ago
  • 3 Vietnamese bloggers charged over their writing | Fox News humbug.in/z/9g #fb 1 month ago
  • Implement strong WiFi encryption the easy way with hostapd - Using WPA2-Personal with individual keys for each user humbug.in/z/9e 1 month ago
  • Soon, wonder vaccine that will kill 90% of cancers - Health - DNA humbug.in/z/9d 1 month ago
  • PHP like str_replace function in C: This post is part of a series of posts where I want to document a bunch of C f... humbug.in/z/9c 1 month ago

Services Offered

  • Embedded Linux Systems and Services
  • Gateway Routers (Frontend and Backend)
  • Free and Open Source Software Solutions
  • Network Monitoring Solutions
  • Device Driver Development


Mobile and Web Analytics

Recent Comments

  • Haakon Dahl commented on Make English the Default Language for Google Chrome Search
    (1 weeks ago)
  • pawan commented on Wordpress Error: The plugin generated 1 characters of unexpected output during activation
    (1 weeks ago)
  • simon commented on Detect Mobile Browser using Server Side Includes (SSI)
    (2 weeks ago)
  • hakatagroup commented on Twitter Weekly Updates between 2012-04-19 and 2012-04-25
    (3 weeks ago)

Tags

Address bar android awk bash C css custom post type debug Default Browser DNS dreamhost English Facebook firefox Google iphone JavaScript jquery KDE keyboard shortcuts Kubuntu Launchpad Linux Mozilla Firefox p2 page template pdf php plugin PPA python ruby ruby-on-rails Ruby1.9.2 Search Results SNMP theme tweets Twitter Ubuntu United States update-alternatives Vietnam wordpress xsl

Copyright © 2012 Humbug.

Powered by WordPress and Hybrid.