Skip to content

Instantly share code, notes, and snippets.

@awinograd
Last active January 30, 2018 22:54

Revisions

  1. awinograd revised this gist Feb 3, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    #! /usr/bin/env ruby

    # Modified from : http://www.tkalin.com/blog_posts/using-console-vim-as-vim-protocol-handler-in-ubuntu
    # NOTE: This opens with a link to the mvim protocol for compatibility with RailsPanel
    # goes to /usr/local/bin/cvim

  2. awinograd created this gist Feb 3, 2013.
    33 changes: 33 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    #! /usr/bin/env ruby

    # NOTE: This opens with a link to the mvim protocol for compatibility with RailsPanel
    # goes to /usr/local/bin/cvim

    require 'uri'
    require 'cgi'

    full_path = ARGV[0]

    # for better_error which encodes the /'s
    full_path = full_path.gsub("%2F", "/")

    if full_path
    full_path = full_path.sub("mvim:\/\/open?url=","")

    uri = URI::parse(full_path)

    path = uri.path

    if path.index('&') > 0
    path = path.split('&')[0]
    params = CGI::parse(uri.path)
    line = params["line"][0]
    else
    path = path
    end

    vim_params = %Q["#{path}"]
    vim_params << " +#{line}" if line
    end

    `gnome-terminal -x vim #{vim_params}`
    14 changes: 14 additions & 0 deletions gistfile2.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # /usr/share/applications/cvim.desktop

    [Desktop Entry]
    Encoding=UTF-8
    Name=Vim (Console)
    Comment=Edit text files in a console using Vim
    Exec=/usr/local/bin/cvim %U
    Terminal=false
    Type=Application
    Icon=/usr/src/vim/runtime/vim48x48.xpm
    Categories=Application;Utility;TextEditor;
    MimeType=text/plain;x-scheme-handler/mvim;
    StartupNotify=true
    StartupWMClass=CVIM