JohnBeckett (talk | contribs) (Add the ==Comments== which we keep even when no comments to encourage new comments in that location. Also some style trivia.) |
m (Changed category Mac OS X → macOS) Tag: Source edit |
||
(One intermediate revision by one other user not shown) | |||
Line 9: | Line 9: | ||
|subpage=/201001 |
|subpage=/201001 |
||
|category1=File Handling |
|category1=File Handling |
||
− | |category2= |
+ | |category2=macOS |
}} |
}} |
||
− | On Mac OS X systems, you can automatically source Vim sessions by creating an Automator Application that forwards the file to Vim with the < |
+ | On Mac OS X systems, you can automatically source Vim sessions by creating an Automator Application that forwards the file to Vim with the <code>-S</code> option. |
==Procedure== |
==Procedure== |
||
− | *Name all your Vim sessions with the same extension, for example "< |
+ | *Name all your Vim sessions with the same extension, for example "<code>.vis</code>". |
*Open ''Automator'' and create a workflow, using ''File > New''. |
*Open ''Automator'' and create a workflow, using ''File > New''. |
||
*Choose ''Application'' as the type for your document. |
*Choose ''Application'' as the type for your document. |
||
Line 39: | Line 39: | ||
==Result== |
==Result== |
||
Whenever you double-click a session file in Finder, will open Vim or MacVim sourcing the saved session.<br /> |
Whenever you double-click a session file in Finder, will open Vim or MacVim sourcing the saved session.<br /> |
||
− | It also works using a command line in ''Terminal'': < |
+ | It also works using a command line in ''Terminal'': <code>$ open test.vis</code> <br /> |
− | And can be useful when Vim is already running: using ''netrw browser'' and hitting < |
+ | And can be useful when Vim is already running: using ''netrw browser'' and hitting <code>"x"</code> while cursor is on file name ''test.vis'' open a new MacVim window with this saved session. |
==Comments== |
==Comments== |
Latest revision as of 14:47, 20 July 2022
Tip 1645 Printable Monobook Previous Next
created January 4, 2010 · complexity basic · author Lotusone · version 7.0
On Mac OS X systems, you can automatically source Vim sessions by creating an Automator Application that forwards the file to Vim with the -S
option.
Procedure[]
- Name all your Vim sessions with the same extension, for example "
.vis
". - Open Automator and create a workflow, using File > New.
- Choose Application as the type for your document.
- In the Library of Actions, choose Utilities.
- From the Utilities section, drag the Run Shell Script action.
- In the Run Shell Script window, choose /bin/bash in Shell pop-up button and as arguments in Pass input pop-up button.
- Write the script:
source ~/.bash_profile # necessary to locate mvim FILE=$@ # the session file to open FILE=${FILE// /\\ } # replace spaces with escaped spaces mvim -S "$FILE" # -S open MacVim sourcing the file
It is possible to write the script in some other language, but bash is more simple.
- Save the Automator Application in some folder that is already in your path.
- Set this application as the default app to open Vim session files (borrowed from the Finder Help):
- Select the document in Finder and choose File > Get Info.
- Click the triangle next to “Open with” to expand the section.
- Choose an application from the pop-up menu, or choose Other to locate a different application.
- If you want to use that application to open all documents of the same type as the current document and created by the same application, click Change All.
Result[]
Whenever you double-click a session file in Finder, will open Vim or MacVim sourcing the saved session.
It also works using a command line in Terminal: $ open test.vis
And can be useful when Vim is already running: using netrw browser and hitting "x"
while cursor is on file name test.vis open a new MacVim window with this saved session.