Mac 下快速新建 “markdwon” 文件

新建命令

可以直接下载这个脚本,解压后双击安装即可。

以下是从0开始的步骤:

  1. 打开 Automator 应用程序。

    image-20240129下午70531321

  2. 选择创建一个新的“快捷操作”:

    image-20240129下午65450736

  3. 搜索AppleScript,并设置如下:

    image-20240130下午42548215

  4. 脚本细节:

    on run {input, parameters}
        set fileName to "readme.md"
       
        tell application "Finder"
            set insertionLocation to (get insertion location) as text
            set targetFile to insertionLocation & fileName
       
            -- 检查文件是否已存在
            if not (exists file targetFile) then
                set blankFile to make new file at insertionLocation with properties {name:fileName}
            else
                display dialog "文件已存在,取消创建.." & fileName buttons {"OK"} default button "OK"
            end if
        end tell
       
        return input
    end run
       
    

添加快捷键

现在,将这个工作流程添加到右键菜单中:

  1. 转到“系统偏好设置” > “键盘” > “快捷键”选项卡。

    image-20240129下午70321009

  2. 在左侧选择“服务”(Services),自定义快捷键。

    image-20240130下午42814352

  3. 除了使用快捷键,在访达的服务中也可以看到这个命令:

    image-20240130下午42940532


xcode 显示文件后缀名 cocoapods 初接触