English 中文(简体)
从Applescript打开MacVim
原标题:Opening MacVim from Applescript

我正在尝试创建一个简单的Applescript,每次单击Finder工具栏上的按钮时都会激活它。这个脚本打开MacVim,工作目录设置为Finder所在的目录。。。

on run
    tell application "Finder" to get folder of the front window as string
    set workingDir to POSIX path of result
    do shell script "cd "" & workingDir & ""; /usr/local/bin/mvim"
end run

这非常有效(mvim自动将MacVim的工作目录设置为cwd)。然而,由于某种原因,这只起作用一次。它在沙滩上玩了一会儿,如果我再点击按钮,什么也没发生。我本以为会得到另一个空白的MacVim窗口——就像我在终端中再次键入mvim一样。

我该如何编写脚本来完成此操作?

最佳回答

www.un.org/ecosoc

iii

do shell script "cd "" & workingDir & ""; /usr/local/bin/mvim > /dev/null 2>&1"

iii

问题回答

This opens the selected files/folders in MacVim.
Works only when a single item is selected in Finder. Works with multiple items selected in Finder.

*****

on run
    tell application "Finder" to set selectedFiles to selection
    if selectedFiles is {} then return    
    set filePathPosix to ""
    repeat with filePath in selectedFiles
        set filePathPosix to filePathPosix & " " & POSIX path of (filePath as alias) & "  "
    end repeat
    do shell script "open -a MacVim " & filePathPosix & " > /dev/null 2>&1"
end run




相关问题
Creating Help Files - Applescript Studio

I would like to know how to generate help files for an applescript studio application I am currently creating. I have tried many different options of creating help, and googled it for quite some time ...

封顶下载和开放式链接

I ve在Angap邮报中设定了一条规则,以操作“Download & Openlink”pple。 我希望这一文字在邮件电文中下载该词,在下载该词之后,该词应开放。

AppleScript to open named terminal window

I have two windows/tabs set up to run in Terminal.app, "syd" and "mel". i.e. in Shell | New Window, "syd" and "mel" are listed. How can I open these terminal configurations with AppleScript?

Hello World Error

I m learning AppleScript and my first program is a Hello World(of course!): display dialog "Hello World" But when I try to run this I got the error: The result of a numeric operation was too ...

User properties/ privileges in AppleScript

I want to write an applescript program that first checks to see if the user has Admin privileges, and if it doesn t then requesting a re-log-in or something. Eventually the script is going to need to ...

Applescript to archive email in Mail.app

I need to write an Applescript for Mail.app that will take all messages in my Inbox and Sent Messages that are older than a certain # of days and move them into respective folders "On My Mac", or ...

热门标签