how to

create a quick action to open folder in terminal

May 14, 2024
快速操作,服务,终端osmacosservice
2 Minutes
277 Words

os: mac14.5

create a quick action to open folder in terminal

创建快速操作以右键在终端中打开文件夹

  • 打开 Automator app,又称自动操作
  • 新建文件
  • 在“选取文稿类型”窗口中选择“快速操作”,点击“选取”
  • 在左侧栏目中拖拽“实用工具 - 运行 Apple Script”到右侧空白处
  • 在顶部栏目中选择“工作流程接收到 自动(无)” “位于 访达.app”
  • 添加以下脚本:
1
on run {input, parameters}
2
tell application "Finder"
3
set currentFolder to (folder of the front window as alias)
4
end tell
5
tell application "iTerm"
6
activate
7
try
8
set currentSession to current session of current window
9
on error
10
create window with default profile
11
set currentSession to current session of current window
12
end try
13
tell currentSession
14
write text "cd " & quoted form of POSIX path of currentFolder
15
end tell
3 collapsed lines
16
end tell
17
return input
18
end run
  • 保存取个名字
  • killall Finder 重启 Finder 后,右键一个文件夹,在“快速操作”栏目中寻找是否有对应服务。

Optional

  • 在设置 - 键盘 - 键盘快捷键 - 服务 - 通用 中为你的服务增加快捷键,(双击快捷键图标后键入新快捷键)比如 cmd + ;
Article title:create a quick action to open folder in terminal
Article author:Julyfun
Release time:May 14, 2024
Copyright 2025
Sitemap