Skip to content

Term At Target

Welcome! This guide 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 developer, a system administrator, or simply a power user, you’ll find that this tool speeds up your workflow and simplifies navigation in the Terminal.

This Shortcut allows you to:

  • Open a new Terminal window.
  • Automatically navigate to a folder of your choice.
  • Choose whether to open the Terminal inside the folder or at its parent directory level.
  • Intelligently handle Finder aliases, letting you choose between the alias location or target location.
  1. Open the Shortcuts app on a Mac (available on macOS Monterey (version 12) and later).
  2. Click the + button to create a new Shortcut.
  3. Name it “Open Terminal in Folder”.
  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

  1. Open the TermAtTarget.applescript file, located on GitHub.
  2. Click the “Copy raw file” button to copy the code.
  3. Return 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.

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

  1. Click the Shortcut Details (i) button in the top-right corner.
  2. Select the Details tab at the top if not already selected.
  3. Check the box for Use as Quick Action.
  4. Check the Finder and Services Menu sub-options.

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

  1. Open Finder.
  2. Select a folder, a file or an alias.
  3. Right-click on the selected item.
  4. Select Quick Actions.
  5. Depending on the macOS version, 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.

When you run the Shortcut for the first time, macOS will display security dialogs asking for permission to allow the Shortcut to interact with Finder and Terminal. Please confirm these requests so that the Shortcut can work properly. Rest assured: your privacy is protected — this Shortcut never transmits any data anywhere, and all actions are performed locally on your Mac.

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).

If you select a file, Terminal will automatically open in the folder that contains that file.

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).

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.

You can change how the Shortcut behaves by editing the following lines of the AppleScript:

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

Change “ASK” to one of these options:

  • ASK - Always asks you each time (default).
  • INSIDE - Always opens inside the selected folder without asking.
  • LEVEL - Always opens at the parent level without asking.

Change “ASK” to one of these options:

  • ASK - Always asks you whether to use alias or target location (default).
  • TARGET - Always uses the target location without asking.
  • ALIAS - Always uses the alias location without asking.

The script includes a debugging system that automatically collects information about execution. If an error occurs, you’ll see a debug log with detailed information that can help diagnose the problem.

The debug log includes:

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

The script uses the open -a Terminal command rather than AppleScript’s direct Terminal handling. This approach prevents an issue where two Terminal windows would open simultaneously.

  • Regular Files and Folders: Handled normally, with folder action prompts for directories.
  • Finder Aliases: Fully supported with options to choose between the alias location or the target.

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.

Current version: 1.2.1.