是否有键盘快捷键(热键)可在macOS中打开终端? [英] Is there a keyboard shortcut (hotkey) to open Terminal in macOS?

查看:91
本文介绍了是否有键盘快捷键(热键)可在macOS中打开终端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Terminal是我用于编程的主要工具之一.当我能够快速打开终端窗口时,它使我的编程过程更有效率.

One of my primary tools used for programming is my Terminal. It makes my programming process more efficient when I'm able to quickly open a Terminal window.

在Ubuntu中,我正在使用( window + Alt + T )打开终端.但是现在我在编程工作中使用Macbook.

In Ubuntu, I was using (window+Alt+T) to open Terminal. But now I use a Macbook at my programming job.

有时我使用Spotlight搜索终端",然后按Enter.

Sometimes I use Spotlight to search "Terminal", and press Enter.

我想知道是否可以分配键盘热键来完成此操作.

I'd like to know if I can assign a keyboard hotkey to do it.

谢谢

推荐答案

我在macOS Mojave 10.14.6(18G3020)下测试了以下过程.

I tested the following procedure under macOS Mojave 10.14.6 (18G3020).

启动自动化器.创建快速操作"类型的文档:

Launch Automator. Create a document of type "Quick Action":

(在旧版本的macOS中,使用服务"模板.)

(In older versions of macOS, use the "Service" template.)

在新的Automator文档中,添加运行AppleScript"操作. (您可以在操作列表顶部的搜索字段中输入"run applescript"来找到它.)这是要粘贴到操作中的AppleScript:

In the new Automator document, add a "Run AppleScript" action. (You can type "run applescript" into the search field at the top of the action list to find it.) Here's the AppleScript to paste into the action:

on run {input, parameters}
    tell application "Terminal"
        if it is running then
            do script ""
        end if
        activate
    end tell
end run

将工作流接收"弹出窗口设置为无输入".总体上看起来应该像这样:

Set the "Workflow receives" popup to "no input". It should look like this overall:

使用新终端"名称保存文档.然后转到Automator菜单(或任何正在运行的应用程序中的应用程序菜单)并打开Services子菜单.现在,您应该可以看到新终端"的快速操作:

Save the document with the name "New Terminal". Then go to the Automator menu (or the app menu in any running application) and open the Services submenu. You should now see the "New Terminal" quick action:

如果单击新终端"菜单项,则会出现一个对话框:

If you click the "New Terminal" menu item, you'll get a dialog box:

单击确定"以允许操作运行.使用该操作时,您将在最前面的每个应用程序中看到一次此对话框.换句话说,当您首次在Finder处于最前面时使用该操作时,您将看到该对话框.而且,当您首次在Safari处于最前面时使用该操作时,您会看到一个对话框.依此类推.

Click OK to allow the action to run. You'll see this dialog once in each application that's frontmost when you use the action. In other words, the first time you use the action while Finder is frontmost, you'll see the dialog. And the first time you use the action while Safari is frontmost, you'll see the dialog. And so on.

在对话框中单击确定"后,终端应打开一个新窗口.

After you click OK in the dialog, Terminal should open a new window.

要将键盘快捷键分配给快速操作,请从服务"菜单中选择服务偏好设置..."项. (或启动系统偏好设置",选择键盘"窗格,然后选择快捷方式"选项卡,然后从左侧列表中选择服务".)滚动到右侧列表的底部,找到新终端"服务.单击它,您应该会看到一个``添加快捷方式''按钮:

To assign a keyboard shortcut to the quick action, choose the "Services Preferences…" item from the Services menu. (Or launch System Preferences, choose the Keyboard pane, then choose the Shortcuts tab, then choose Services from the left-hand list.) Scroll to the bottom of the right-hand list and find the New Terminal service. Click it and you should see an "Add Shortcut" button:

单击按钮,然后按您的首选键盘快捷键.然后,挠头,因为(当我尝试过)添加快捷方式"按钮会再次出现.但是,再次单击该按钮,您应该会看到快捷方式:

Click the button and press your preferred keyboard shortcut. Then, scratch your head, because (when I tried it) the Add Shortcut button reappears. But click the button again and you should see your shortcut:

现在,在大多数情况下,您应该可以按下键盘快捷键以获取新的终端窗口.

Now you should be able to press your keyboard shortcut in most circumstances to get a new terminal window.

这篇关于是否有键盘快捷键(热键)可在macOS中打开终端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆