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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,437评论 19 139
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 178,247评论 25 709
  • 上周末(5.13-5.14)公司安排的旅游,去桐乡游山玩水。这是例行的每年一次公司旅游,相较于前几年,今年的旅游条...
    Anita解忧愁阅读 646评论 0 0
  • 对于安全感的发展,你需要两手抓,一手抓现实关系的安全感,一手抓内心自我关系的安全感。现实的关系是指,和愿意尊重你、...
    清水微甜的日常阅读 567评论 0 0
  • 连天空都知道我想你了所以它下雨了……
    孤独伊人阅读 293评论 0 0

友情链接更多精彩内容