Skip to content

Instantly share code, notes, and snippets.

@btelles
Created June 5, 2010 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save btelles/426945 to your computer and use it in GitHub Desktop.
Save btelles/426945 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
# the following maps the protocol handler txmt to open a vim file
# For example, if you have a link in Firefox with this URL:
#
# txmt:///home/my_user/.../index.html.haml
#
# then you can use this script to open VIM in the to the
# corresponding file and line number.
#
# See stackoverflow:
# http://stackoverflow.com/questions/2981428/is-there-a-way-to-click-a-link-in-firefox-and-open-a-file-in-an-existing-vim-sess
#
file_result = ARGV[0].scan(/file\:\/\/((\w|\/|\.)*).*/)
file_path = file_result[0][0]
line_result = ARGV[0].scan(/\&amp\;line\=(\d*).*/)
if line_result
line = line_result[0][0]
system "gvim --remote-silent +#{line} #{file_path}"
else
system "gvim --remote-silent #{file_path}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment