Say I am in a Finder window (eg: ~/Documents/code ) and I want to be able to use a keyboard shortcut to open a terminal window with the prompt

user@computer: ~/Documents/code$

Most of the questions are answered using mouse.

2 Answers 2


In System Preferences > Keyboard > Shortcuts > Services under Files and Folders there is a New Terminal at Folder shortcut which you can assign a keyboard shortcut to; however, it only appears on the Finder > Services menu, or the right-click context menu, when a Folder is selected. So if you have a Finder window open but no additional folder selected, it is not available. This may be fine for one's particular usage, but if not, then here is an alternative.

For example, say you have a Finder window open to your Downloads folder, which is selected in the Sidebar, and you want to open a Terminal window there. Well the built in service isn't available because an individual Folder isn't selected and what's selected in the Sidebar doesn't count...

One way to open a Terminal window at the location of the current Finder window, using a keyboard shortcut, is to use AppleScript in an Automator Service (Quick Action in macOS Mojave), then assign it a keyboard shortcut in: System Preferences > Keyboard > Shortcuts > Services > ...

  1. Create an Automator Service adding a Run AppleScript action, then replace the default code with the example AppleScript code shown below.

  2. Save the service as e.g. Open Terminal Here with the settings as shown in the image below. Then assign it a keyboard shortcut. It should show under the General section of the aforementioned path.

    • Note: After assigning it a keyboard shortcut, you may have to trigger the new service one time with the mouse from the Finder > Services menu for it to work subsequently using the assigned keyboard shortcut.
    • Additionally, the assigned keyboard shortcut cannot be one that is already in use by Finder. I wanted to use ^⌘T but it would not work, so I settled for: ^⌘\
    • Accessibility privileges for Automator may need to be granted for this service to work properly.

Example AppleScript code:

tell application "Finder"
    if exists Finder window 1 then
        set currentFolder to target of Finder window 1 as alias
    end if
end tell
tell application "Terminal"
    do script "cd " & quoted form of POSIX path of currentFolder & "; clear"
end tell

Automator Service

As an added bonus, you can also use the example AppleScript code saved as an AppleScript application in Script Editor and place it in the Toolbar of Finder, thus allowing one to click the icon to open a Terminal window at the current location when one wants versus using the keyboard short assigned to the Automator service. No third-party app required!

  1. In Script Editor, save the example AppleScript code as an AppleScript application, as e.g.: Open Terminal Here
  2. In Finder, give it the same icon as Terminal.
    • From Finder, open the Get Info sheet for both the e.g.: Open Terminal Here app and Terminal, by selecting each and pressing: ⌘I
    • With both Get Info sheets showing, select the icon in the upper left corner of the one for Terminal and press: ⌘C
    • Now select the icon in the upper left corner of the one for e.g.: Open Terminal Here and press: ⌘V
    • Close the Get Info sheets.
    • Drag an drop, while holding the key1, the app bundle for the e.g.: Open Terminal Here app onto the Toolbar in Finder.
              1 Required in later versions of OS X/macOS.

Open Terminal Here on Finder's Toolbar

Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors.

  • Thanks for the answer. It's very detailed and more complicated than I expected. I will get back to you very soon.
    – Morpheus
    Commented May 9, 2019 at 15:04
  • I wanted to say that your answer is working well. But I had to fiddle with creating the service a bit. I had some difficulty in creating the automator service but I was finally able to figure it out. Thanks!
    – Morpheus
    Commented May 17, 2019 at 8:51
  • 2
    This is brilliant! Still working great on Big Sur on an M1 Mac
    – Martin
    Commented Dec 30, 2020 at 8:05

There is a 3rd party app named gotoshell available at the Macapp Store for free. This app enables you to put a small icon on your finder window tool bar. When you click the icon, a terminal or iterm2 window opens at the same directory as the finder window. The icon appears on all finder windows. An image of icon is shown below.

enter image description here

  • 1
    The OP explicitly stated "I want to be able to use a keyboard shortcut to open a terminal window with the prompt" and further said "Most the the questions are answered using mouse.", so does the third-party app you've mentioned also allow assigning a keyboard shortcut? Commented May 9, 2019 at 17:15
  • I assumed erroneously that he just wanted a simple way to open the terminal at the proper place. I will delete my answer shortly. I'd like for OP to at least read the answer because if he is using the Finder to go somewhere the app follows him and he just clicks it. If he's using the terminal to go somewhere then he doesn't need a shortcut.
    – Natsfan
    Commented May 9, 2019 at 18:12
  • 1
    He my be keyboard centric versus mouse centric and why he explicitly asked for a keyboard shortcut; however, I also included in my answer a way to use the existing code in a AppleScript application to be placed in the Toolbar of Finder for the occasion when one wants to click to get the same result. No third-party-app needed. Commented May 9, 2019 at 18:16
  • Yep your answer is spot on. Its simple to do but you have to set it up and type the keyboard shortcut. I was just offering the OP a slightly easier solution although its not keyboard centric as he requested...
    – Natsfan
    Commented May 9, 2019 at 22:04
  • @jmh I do navigate using mouse but sometimes when I am in folder, I open and close terminals a lot and would love to have a keyboard shortcut. Thanks for the solution anyway.
    – Morpheus
    Commented May 17, 2019 at 8:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .