I often run into web links that are plain text and eventually got annoyed enough to write this extremely simple script. It works by using xclip to grab what you have highlighted and if the contents look like an http address it will open in your browser of choice. As a bonus, if it doesn’t look like an http address it will open up google maps and attempt to map the contents. It should be obvious that this can easily be extended to suit other purposes.
#!/usr/bin/ruby
x = `xclip -o`
if x =~ /^[ \t]*https?:\/\/.*/ # Goto web address
`gnome-open #{x}`
else # Map location
`gnome-open http://maps.google.com/?q=#{x.gsub(/[ \t\n]+/, '+')}`
end
In order to install the script, copy the script above and save as $HOME/bin/controlshiftz.rb and make it executable. To bind it to a key combination in gnome use the following two commands. By default this will cause control-shift-z to activate the script. You will also need to install the xclip package.
gconftool-2 -s /apps/metacity/keybinding_commands/command_1 -t string $HOME/bin/controlshiftz.rb
gconftool-2 -s /apps/metacity/global_keybindings/run_command_1 -t string '<Control><Shift>z'
If you extend the script in an interesting way, comment or send me an email about it.