第一步:打开Mac自带程序自动操作
,新建快速操作
第二步:点击操作,选择资源库
下面的实用工具
,点击运行AppleScript
拖入到右边
第三步:将下面的代码放到AppleScript里面,保存为Open iTerm
on run {input, parameters}
tell application "Finder"
set pathList to (quoted form of POSIX path of (folder of the front window as alias))
set command to "clear; cd " & pathList
end tell
tell application "System Events"
-- some versions might identify as "iTerm2" instead of "iTerm"
set isRunning to (exists (processes where name is "iTerm")) or (exists (processes where name is "iTerm2"))
end tell
tell application "iTerm"
activate
set hasNoWindows to ((count of windows) is 0)
if isRunning and hasNoWindows then
create window with default profile
end if
select first window
tell the first window
if isRunning and hasNoWindows is false then
create tab with default profile
end if
tell current session to write text command
end tell
end tell
end run
代码意思是将当前最前面的Finder地址如果获取不到,则返回桌面地址
然后通知iTerm的第一个窗口新建标签并跳到这个目录去
第四步:打开系统偏好设置
-》键盘
-》快捷键
-》服务
注意:设置的快捷键不能与
Finder
自带快捷键冲突。