Skip to content

Term At Target

This guide shows how to open Terminal at a Finder location using a Shortcut and AppleScript.

This Shortcut can:

  • Open Terminal at a selected Finder location.
  • Handle files, folders, and Finder aliases.
  • Ask whether to open inside a selected folder or at its parent level.
  • Ask whether alias selection should use alias location or target location.
  • Prevent immediate duplicate launches with a run lock.
  • macOS with Shortcuts app and Terminal app.
  • Shortcut includes:
  1. Get Selected Files in Finder
  2. Run AppleScript
  1. Open the Shortcuts app.
  2. Click + to create a new Shortcut.
  3. Name it Open Terminal in Folder.
  4. Add Get Selected Files in Finder.
  5. Add Run AppleScript.

macOS Shortcuts app (on macOS 15): Shortcut initialization

  1. Open TermAtTarget.applescript.
  2. Copy the raw script.
  3. Return to Shortcuts.
  4. Click inside the Run AppleScript action.
  5. Paste the script.
  6. Click outside the action so changes are saved.

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

  1. Open Shortcut Details (i button).
  2. In Details, enable Use as Quick Action.
  3. Enable Finder and Services Menu options.

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

  1. Open Finder.
  2. Select a folder, file, or alias.
  3. Run the Shortcut from Quick Actions or Services.

You can choose:

  • Open Terminal INSIDE this folder
  • Open Terminal at this folder's LEVEL

Terminal opens at the file’s containing folder.

You can choose:

  • Open Terminal at TARGET location
  • Open Terminal at ALIAS location

If target is a folder and you choose TARGET, folder behavior still applies (INSIDE or LEVEL).

The script prompts you to choose a folder.

Edit these properties in the AppleScript:

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

Folder action behavior:

  • ASK - Prompt every run.
  • INSIDE - Always open inside selected folder.
  • LEVEL - Always open at parent of selected folder.

Alias action behavior:

  • ASK - Prompt every run.
  • TARGET - Always use alias target location.
  • ALIAS - Always use alias file location.
  • If files/folders are duplicated, check keyboard shortcut conflicts first.
  • Do not assign this Shortcut to ⌘D (Finder Duplicate).
  • If Terminal opens twice, check that Shortcut trigger is not assigned in multiple places.
  • Confirm Finder and Terminal permissions when prompted by macOS.
  • Terminal launch uses open -a Terminal <path>, rather than AppleScript’s direct Terminal handling. This approach prevents an issue where two Terminal windows would open simultaneously.
  • Script returns {} to avoid passing Finder input downstream.
  • Alias and folder routing is handled explicitly through script options.

Created by Ervins Strauhmanis. Licensed under MIT. Current version: 1.3.0.