Right here is an AppleScript script to make it potential double-click information in Finder in order that they are going to be opened in Vim, by Normen Hansen: https://github.com/normen/vim-macos-scripts/blob/grasp/open-file-in-vim.applescript (it should be used from Automator).
I attempt to simplify it and likewise to make it potential to make use of it with out Automator. To make use of my very own model, you solely want to reserve it as software as a substitute, like this:
osacompile -o open-with-vim.app open-with-vim.applescript
after which copy it to /Functions
and set your .txt
information to be opened utilizing this app.
Right here it’s, it alsmost works:
-- https://github.com/normen/vim-macos-scripts/blob/grasp/open-file-in-vim.applescript -- opens Vim with file or file record -- units present folder to mother or father folder of first file on open theFiles set command to {} if enter is null or enter is {} or ((merchandise 1 in enter) as string) is "" then -- no information, open vim with out parameters set finish of command to "vim;exit" else set firstFile to (merchandise 1 of theFiles) as string inform software "Finder" to set pathFolderParent to quoted type of (POSIX path of ((folder of merchandise firstFile) as string)) set finish of command to "cd" & area & (pathFolderParent as string) set finish of command to ";hx" -- e.g. vi or every other command-line textual content editor set fileList to {} repeat with i from 1 to (theFiles depend) set finish of fileList to area & quoted type of (POSIX path of (merchandise i of theFiles as string)) finish repeat set finish of command to (fileList as string) set finish of command to ";exit" -- if Terminal > Settings > Profiles > Shell > When the shell exits != Do not shut the window finish if set command to command as string set myTab to null inform software "Terminal" if it isn't working then set myTab to (do script command in window 1) else set myTab to (do script command) finish if activate finish inform return finish open
The one downside is the if
block within the very starting:
if enter is null or enter is {} or ((merchandise 1 in enter) as string) is "" then
What’s fallacious there? make it work? (Assuming it already works fantastic if AppleScript is used utilizing Automator.)