9.1 C
United States of America
Sunday, November 24, 2024

keybindings – Keyboard shortcut to open Terminal on the present folder location in Finder


In System Preferences > Keyboard > Shortcuts > Companies below Recordsdata and Folders there’s a New Terminal at Folder shortcut which you’ll assign a keyboard shortcut to; nonetheless, it solely seems on the Finder > Companies menu, or the right-click context menu, when a Folder is chosen. So if in case you have a Finder window open however no further folder chosen, it isn’t obtainable. This can be nice for one’s explicit utilization, but when not, then right here is another.

For instance, say you’ve got a Finder window open to your Downloads folder, which is chosen within the Sidebar, and also you wish to open a Terminal window there. Properly the in-built service is not obtainable as a result of a person Folder is not chosen and what’s chosen within the Sidebar does not depend…

One approach to open a Terminal window on the location of the present Finder window, utilizing a keyboard shortcut, is to make use of AppleScript in an Automator Service (Fast Motion in macOS Mojave), then assign it a keyboard shortcut in: System Preferences > Keyboard > Shortcuts > Companies >

  1. Create an Automator Service including a Run AppleScript motion, then exchange the default code with the instance AppleScript code proven beneath.

  2. Save the service as e.g. Open Terminal Right here with the settings as proven within the picture beneath. Then assign it a keyboard shortcut. It ought to present below the Common part of the aforementioned path.

    • Word: After assigning it a keyboard shortcut, you’ll have to set off the brand new service one time with the mouse from the Finder > Companies menu for it to work subsequently utilizing the assigned keyboard shortcut.
    • Moreover, the assigned keyboard shortcut can’t be one that’s already in use by Finder. I wished to make use of ^⌘T however it might not work, so I settled for: ^⌘
    • Accessibility privileges for Automator could have to be granted for this service to work correctly.

Instance AppleScript code:

inform software "Finder"
    if exists Finder window 1 then
        set currentFolder to focus on of Finder window 1 as alias
    else
        return
    finish if
finish inform
inform software "Terminal"
    do script "cd " & quoted type of POSIX path of currentFolder & "; clear"
    activate
finish inform

Automator Service


As an added bonus, you can too use the instance AppleScript code saved as an AppleScript software in Script Editor and place it within the Toolbar of Finder, thus permitting one to click on the icon to open a Terminal window on the present location when one desires versus utilizing the keyboard brief assigned to the Automator service. No third-party app required!

  1. In Script Editor, save the instance AppleScript code as an AppleScript software, as e.g.: Open Terminal Right here
  2. In Finder, give it the identical icon as Terminal.
    • From Finder, open the Get Information sheet for each the e.g.: Open Terminal Right here app and Terminal, by choosing every and urgent: ⌘I
    • With each Get Information sheets exhibiting, choose the icon within the higher left nook of the one for Terminal and press: ⌘C
    • Now choose the icon within the higher left nook of the one for e.g.: Open Terminal Right here and press: ⌘V
    • Shut the Get Information sheets.
    • Drag an drop, whereas holding the ⌘ key1, the app bundle for the e.g.: Open Terminal Right here app onto the Toolbar in Finder.

              1 Required in later variations of OS X/macOS.

Open Terminal Here on Finder's Toolbar


Word: The instance AppleScript code is simply that and doesn’t include any error dealing with as could also be applicable. The onus is upon the consumer so as to add any error dealing with as could also be applicable, wanted or wished. Take a look on the strive assertion and error assertion within the AppleScript Language Information. See additionally, Working with Errors.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles