Loading ...
Sorry, an error occurred while loading the content.

Double-click to open file in console vim

Expand Messages
  • foosh
    One more question: Is it possible to start a terminal session with vim editing a text file that I ve double-clicked on in the Finder? I.e., rather than using
    Message 1 of 4 , Oct 31, 2007
    • 0 Attachment
      One more question:

      Is it possible to start a terminal session with vim editing a text
      file that I've double-clicked on in the Finder?

      I.e., rather than using Vim.app at all, I'd love to just double-click
      on a .txt file and have it open a terminal window running "vim
      $filename". This strikes me as a stretch, but I thought I'd ask...
      Any help greatly appreciated!


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Ben Schmidt
      ... It can definitely be done, but may be a bit of work. A little utility called Platypus allows you to create .apps that start shell scripts. By making such
      Message 2 of 4 , Nov 1, 2007
      • 0 Attachment
        > One more question:
        >
        > Is it possible to start a terminal session with vim editing a text
        > file that I've double-clicked on in the Finder?
        >
        > I.e., rather than using Vim.app at all, I'd love to just double-click
        > on a .txt file and have it open a terminal window running "vim
        > $filename". This strikes me as a stretch, but I thought I'd ask...
        > Any help greatly appreciated!

        It can definitely be done, but may be a bit of work. A little utility called
        Platypus allows you to create .apps that start shell scripts. By making such an
        app with a shell script to open a terminal window, you should be able to manage it.

        http://www.sveinbjorn.org/platypus

        You can get a terminal window to open using Applescript. And in a shell script you
        can run AppleScript with osascript. I think this would work:

        #!/bin/bash
        osascript << END
        tell application "Terminal" to do script "vim \"$1\" ; exit"
        END

        Use Playpus to wrap that up into a .app and you should have a solution.

        Ben.




        Send instant messages to your online friends http://au.messenger.yahoo.com


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_mac" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • foosh
        ... Thanks for your response! I actually found another solution before reading yours. Open Script Editor.app and do something like: on open inputfile ignoring
        Message 3 of 4 , Nov 1, 2007
        • 0 Attachment
          On Nov 1, 2:12 am, Ben Schmidt <mail_ben_schm...@...> wrote:
          > It can definitely be done, but may be a bit of work. A little utility called
          > Platypus allows you to create .apps that start shell scripts. By making such an
          > app with a shell script to open a terminal window, you should be able to manage it.

          Thanks for your response!

          I actually found another solution before reading yours.

          Open Script Editor.app and do something like:
          on open inputfile
          ignoring application responses
          tell application "Terminal"
          activate
          do script "vim " & quoted form of POSIX path of inputfile
          end tell
          end ignoring
          end open

          Then compile it as an application and you can then set the
          resulting .app as the default "open with" program for your filetype of
          choice.


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_mac" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Ben Schmidt
          ... OK, cool. Basically the same solution. I did vaguely think of a script application but thought it might not work associating files with it, but if it does,
          Message 4 of 4 , Nov 1, 2007
          • 0 Attachment
            > I actually found another solution before reading yours.
            >
            > Open Script Editor.app and do something like:
            > on open inputfile
            > ignoring application responses
            > tell application "Terminal"
            > activate
            > do script "vim " & quoted form of POSIX path of inputfile
            > end tell
            > end ignoring
            > end open
            >
            > Then compile it as an application and you can then set the
            > resulting .app as the default "open with" program for your filetype of
            > choice.

            OK, cool. Basically the same solution. I did vaguely think of a script application
            but thought it might not work associating files with it, but if it does, that's great!

            Ben.



            Send instant messages to your online friends http://au.messenger.yahoo.com


            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_mac" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          Your message has been successfully submitted and would be delivered to recipients shortly.