Pāriet uz saturu

Open Terminal in Folder

Šis saturs vēl nav pieejams jūsu valodā.

Welcome! This guide (the unboring edition) will show you how to quickly open a Terminal window in any folder on your macOS system using a handy Shortcut. Whether you’re a code coyote, a system administrator, or simply a power weasel, this tool will turbocharge your workflow and downgrade the excitement of navigating folders via Terminal to the level of watching paint dry — on mute!

What it Does

This Shortcut allows you to:

  • Spawn a new Terminal window.
  • Magically navigate to a folder of your choice.
  • Choose whether to open the Terminal inside the folder or at its parent directory level.
  • Handle those sneaky Finder aliases, letting you choose between the alias location or target location.

How to Install

Step 1: Initialize Your Shortcut

  1. Open the Shortcuts app on a Mac (available on macOS Monterey (version 12) and later, you dinosaur).
  2. Click the + button to create a new Shortcut.
  3. Name it “Open Terminal in Folder” (or “Command Line Magic”, if you’re feeling adventurous).
  4. Add the Get Selected Files in Finder action from the sidebar.
  5. Add a Run AppleScript action.

macOS Shortcuts app (on macOS 15): Shortcut initialization

Step 2: Add the AppleScript Code

  1. Open the OpenTerminalInFolder.applescript file, lurking on GitHub.
  2. Click the “Copy raw file” button to snag the code.
  3. Scoot back to the Shortcuts app.
  4. Click inside the AppleScript action box.
  5. Paste the code (⌘+V).
  6. Click somewhere outside the AppleScript action box (for example, on already existing Get Selected Files in Finder action above), to ensure the code gets saved (otherwise your Mac might throw a tantrum).

macOS Shortcuts app (on macOS 15): Adding AppleScript code

Step 3: Configure Shortcut Details

  1. Click the Shortcut Details (i) button in the top-right corner.
  2. Select the Details tab at the top if it’s not already winking at you.
  3. Check the box for Use as Quick Action (because slow actions are for chumps).
  4. Check the Finder and Services Menu sub-options.

macOS Shortcuts app (on macOS 15): Configuring the Shortcut’s Details

How to Use

Basic Usage (The Simple Stuff)

  1. Open Finder (you know, that blue smiley face thingy).
  2. Select a folder, a file or an alias.
  3. Right-click on the selected item (or two-finger tap if you’re a trackpad snob).
  4. Select Quick Actions.
  5. If your macOS is being a drama queen, you may need to select Customize…, and turn on the Open Terminal in Folder Shortcut with a toggle switch.
  6. Launch the Open Terminal in Folder Shortcut and watch the magic unfold.

macOS Privacy & Security Permissions

When you run the Shortcut for the first time, macOS will bombard you with security dialogs asking for permission to allow the Shortcut to interact with Finder and Terminal. Just approve them all so the Shortcut can do its thing. Don’t worry, this Shortcut isn’t some creepy data-sniffing monster – it never transmits your precious data anywhere, and all operations happen locally on your Mac. Pinky swear!

When You Select a Folder

If you select a folder, you’ll be asked:

  • “Open Terminal INSIDE this folder” — Opens Terminal in the folder you selected.
  • “Open Terminal at this folder’s LEVEL” — Opens Terminal in the parent folder (the folder that contains your selected folder).

When You Select a File

If you select a file, Terminal will automatically open in the folder that contains that file. No questions asked. It’s not rocket science.

When You Select a Finder Alias (Plot Twist!)

If you select a Finder alias (created with Finder’s “Make Alias” command), you’ll be presented with additional options:

  • “Open Terminal at TARGET location” — Opens Terminal at the location of the original file/folder the alias points to.
  • “Open Terminal at ALIAS location” — Opens Terminal in the folder containing the alias itself.

If the alias points to a folder and you choose “TARGET location,” you’ll then be asked the standard folder question (INSIDE or LEVEL).

When You Don’t Select Anything

If you run the Shortcut without selecting anything in Finder, it will ask you to choose a folder.

Note: Right-clicking on a file or folder without first left-clicking it does not count as selecting it. No mind readers here!

Customization

You can change how the Shortcut behaves by editing the following lines of the AppleScript (if you dare):

property defaultFolderAction : "ASK" -- Options: "ASK", "INSIDE", "LEVEL"
property defaultAliasAction : "ASK" -- Options: "ASK", "TARGET", "ALIAS"

Folder Action Options

Change “ASK” to one of these options:

  • ASK - Always bugs you each time (default for the indecisive).
  • INSIDE - Always opens inside the selected folder without asking (for decisive types).
  • LEVEL - Always opens at the parent level without asking (for those with parent issues).

Alias Action Options

Change “ASK” to one of these options:

  • ASK - Always asks you whether to use alias or target location (default for the commitment-phobic).
  • TARGET - Always uses the target location without asking (for the no-nonsense crowd).
  • ALIAS - Always uses the alias location without asking (for the literal-minded).

Troubleshooting

The script includes a debugging system that automagically collects information about what the heck went wrong. If an error pops up, you’ll see a debug log with all the gory details to help figure out why your computer is throwing a tantrum.

The debug log includes:

  • File types and classifications
  • Path information
  • Action selections
  • Error details

Technical Notes (Nerd Alert!)

Terminal Launching Method

The script uses the open -a Terminal command rather than AppleScript’s direct Terminal handling. This clever approach prevents that annoying issue where two Terminal windows would pop open simultaneously, the dreaded twins.

File Type Handling

  • Regular Files and Folders: Handled normally, with folder action prompts for directories (yawn).
  • Finder Aliases: Fully supported with options to choose between the alias location or the target (ooh, choices!).
  • Symbolic Links: Unix symbolic links (created with ln -s) are not supported because macOS/AppleScript/Finder have some weird hangups about handling symlinks. It’s not you, it’s them.

About This Shortcut

This Shortcut was created by Ervins Strauhmanis and is licensed under the MIT License. This means you are free to use, modify, and share it as needed without getting sued. Hooray for open source!

Current version: 1.2.0 (The Squirrel Girl Edition).

Need Help? (Of Course You Do)

If something’s broken or you have brilliant ideas for new features, please file an Issue on GitHub (the digital complaint department).

Coffee! (Shameless Begging)

Loving how this Shortcut makes your life marginally less frustrating? Consider tossing a coffee-sized thank you to the developer who sacrificed sleep to make it possible! Because code doesn’t write itself, and caffeine isn’t free.

© 2025 Ervins Strauhmanis.
Privacy Policy Terms of Use