AppleScirpt设置打开Terminal快捷键
来源:互联网 发布:minecraft java版 编辑:程序博客网 时间:2024/04/30 22:42
前几天学习了下appleScirpt,用它写了个在当前文件夹打开Terminal的小程序,配置成service方便平时使用.
基本思路
1.编写脚本:appleScirpt获取当前文件夹路径.启动Termianl,cd到当前文件夹路径2.在Automator中设置service,调用脚本3.在快捷键设置中增加该service的快捷键
编写脚本
```on run -- 当程序开始运行https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_handlers.html#//apple_ref/doc/uid/TP40000983-CH7g-SW2try tell application "Finder" (* POSIX path是类似这种 /usr/Documents http://www.satimage.fr/software/en/smile/external_codes/file_paths.html *) set currFolder to POSIX path of (folder of the front window as string) end tellon error set currFolder to (path to home folder as string)end trytell application "Terminal" if it is running then set itermisrunning to true else set itermisrunning to false end ifactivate -- 文档解释Brings an application to the front, and opens it if it is on the local computer and not already running. if itermisrunning = true then tell application "System Events" to keystroke "t" using command down end ifdo script ("cd " & "'" & currFolder & "'") in front windowend tellend ru```Terminal支持的applescriptAPI查询:Scirpt Editor -> File -> Open Directionary -> Terminal -> Choose
添加service
打开Automator,按下图找到run applescript,然后双击.这个操作是创建调用applescript的service.
如下图,将代码复制到输入框,Service receives为 no input
保存command + s,名称命名为open
这样一个service就建成了
在快捷键设置中增加该service的快捷键
打开快捷键设置 System Preferences -> Keyboard -> Short cuts -> Services -> 选中 openTerminal
然后选中右边,设置快捷键.快捷键如果设置为按住control + o,则按住control键,再按住o键,就设置上了
0 0
- AppleScirpt设置打开Terminal快捷键
- 如何在RedHat下设置打开Terminal终端快捷键
- 设置终端(terminal)快捷键
- centos7设置Terminal快捷键
- CentOs6.5设置terminal快捷键
- fedora创建快捷键打开终端(terminal)
- fedora创建快捷键打开终端(terminal)
- fedora创建快捷键打开终端(terminal)
- mac os x 设置Terminal快捷键
- Terminal快捷键
- terminal 快捷键
- terminal 快捷键
- Centos桌面条件下打开Terminal的快捷键是什么呢?
- 在Linux桌面条件下打开Terminal的快捷键
- 设置打开Finder的快捷键
- CentOS设置打开终端快捷键
- CentOS设置打开终端快捷键
- ubuntu terminal 常用快捷键
- Intellj Idea 的默认首页修改
- oracle 9i/10g/11g(11.2.0.3)安装包和PATCH下载地址汇总
- TraceView的使用方法
- 统计分析基础 (一) 数据统计与图表
- u-boot-2016.5启动流程
- AppleScirpt设置打开Terminal快捷键
- C++ 常用泛型算法的使用
- 多图详解Spring框架的设计理念与设计模式
- JMM和synchronize的一些记录:
- JVM内存区域介绍
- 软件测试的一些理解
- Android基础(三)
- Leetcode 234. Palindrome Linked List (Easy) (cpp)
- Integer to English Words