Is there a keyboard shortcut (hotkey) to open Terminal in macOS?

后端 未结 3 517
眼角桃花
眼角桃花 2020-12-22 17:08

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.

In Ubun

相关标签:
3条回答
  • 2020-12-22 17:27

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

    Launch Automator. Create a document of type “Quick Action”:

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

    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:

    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:

    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.

    0 讨论(0)
  • 2020-12-22 17:28

    iTerm2 - an alternative to Terminal - has an option to use configurable system-wide hotkey to show/hide (initially set to Alt+Space, disabled by default)

    0 讨论(0)
  • 2020-12-22 17:30

    As programmers we want the quickest, most fool-proof way to get our tools in order so we can start hacking. Here are how I got it to work in MacOS 10.13.1 (High Sierra):

    • Option 1: Go to System Preferences | Keyboard | Shortcut | Services. Under Files and Folders section, enable New Terminal at Folder and/or New Terminal Tab at Folder and assign a shortcut key to it.

    • Option 2: If you want the shortcut key to work anywhere, create a new Service using Automator, then go to the Keyboard Shortcut to assign a shortcut key to it. Known limitation: not work from the desktop

    Notes:

    • If the shortcut doesn't work, it might be in conflict with another key binding (and the OS wouldn't warn you), try something else, e.g. if ⇧⌥T doesn't work, try ⇧⌘T.
    • Don't spell-correct MacOS, that's not necessary.
    0 讨论(0)
提交回复
热议问题