第一步:打开Mac自带程序自动操作,新建快速操作

开始创建服务

参数设置

第二步:点击操作,选择资源库下面的实用工具,点击运行AppleScript拖入到右边

添加服务

第三步:将下面的代码放到AppleScript里面,保存为Open iTerm
 1on run {input, parameters}
 2    tell application "Finder"
 3        set pathList to (quoted form of POSIX path of (folder of the front window as alias))
 4        set command to "clear; cd " & pathList
 5    end tell
 6    tell application "System Events"
 7        -- some versions might identify as "iTerm2" instead of "iTerm"
 8        set isRunning to (exists (processes where name is "iTerm")) or (exists (processes where name is "iTerm2"))
 9    end tell
10    tell application "iTerm"
11        activate
12        set hasNoWindows to ((count of windows) is 0)
13        if isRunning and hasNoWindows then
14            create window with default profile
15        end if
16        select first window
17        tell the first window
18            if isRunning and hasNoWindows is false then
19                create tab with default profile
20            end if
21            tell current session to write text command
22        end tell
23    end tell
24end run

代码意思是将当前最前面的Finder地址如果获取不到,则返回桌面地址 然后通知iTerm的第一个窗口新建标签并跳到这个目录去

第四步:打开系统偏好设置-》键盘-》快捷键-》服务

注意:设置的快捷键不能与Finder自带快捷键冲突。

第五步:重启Finder,打开终端输入:killall Finder
第六步:随意进入一个文件夹,使用快捷键吧~
个人笔记记录 2021 ~ 2025