mac中將vim添加到右鍵菜單

  1. 創建 vim.app 到應用程序目錄:
image.png

vim.app 代碼如下

on run {input}
    if length of input is equal to 1 then
        my openFile(input)
    else
        my justOpen()
    end if
end run


on openFile(input)
    set the_file to quoted form of POSIX path of input
    tell application "System Events"
        set the_path to POSIX path of (container of (item 1 of input))
    end tell
    
    set cwd to "cd " & the_path
    set cmd to "vim " & the_file
    my launchVim(cwd, cmd)
end openFile


on justOpen()
    set cwd to "cd"
    set cmd to "vim"
    my launchVim(cwd, cmd)
end justOpen


on launchVim(cwd, cmd)
    tell application "System Events" to set terminalIsRunning to exists application process "Terminal"
    
    tell application "Terminal"
        activate
        if terminalIsRunning is true then
            tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
            do script with command cwd in selected tab of the front window
            do script with command cmd in selected tab of the front window
        else
            do script with command cwd in window 1
            do script with command cmd in window 1
        end if
    end tell
end launchVim
image.png
  1. 創建服務
image.png
image.png
image.png
image.png
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • Spring Cloud為開發人員提供了快速構建分布式系統中一些常見模式的工具(例如配置管理,服務發現,斷路器,智...
    卡卡羅2017閱讀 134,981評論 19 139
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 173,466評論 25 708
  • 上周末(5.13-5.14)公司安排的旅游,去桐鄉游山玩水。這是例行的每年一次公司旅游,相較于前幾年,今年的旅游條...
    Anita解憂愁閱讀 583評論 0 0
  • 對于安全感的發展,你需要兩手抓,一手抓現實關系的安全感,一手抓內心自我關系的安全感。現實的關系是指,和愿意尊重你、...
    清水微甜的日常閱讀 494評論 0 0
  • 連天空都知道我想你了所以它下雨了……
    孤獨伊人閱讀 284評論 0 0