Created
June 5, 2010 19:50
-
-
Save btelles/426945 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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(/\&\;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