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.
What it Does
Section titled “What it Does”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.
How to Install
Section titled “How to Install”Step 1: Initialize Your Shortcut
Section titled “Step 1: Initialize Your Shortcut”- Open the Shortcuts app on a Mac (available on macOS Monterey (version 12) and later).
- Click the + button to create a new Shortcut.
- Name it “Open Terminal in Folder”.
- Add the
Get Selected Files in Finder
action from the sidebar. - Add a
Run AppleScript
action.
Step 2: Add the AppleScript Code
Section titled “Step 2: Add the AppleScript Code”- Open the TermAtTarget.applescript file, located on GitHub.
- Click the “Copy raw file” button to copy the code.
- Return to the Shortcuts app.
- Click inside the AppleScript action box.
- Paste the code (⌘+V).
- 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.
Step 3: Configure Shortcut Details
Section titled “Step 3: Configure Shortcut Details”- Click the Shortcut Details (i) button in the top-right corner.
- Select the Details tab at the top if not already selected.
- Check the box for Use as Quick Action.
- Check the Finder and Services Menu sub-options.
How to Use
Section titled “How to Use”Basic Usage
Section titled “Basic Usage”- Open Finder.
- Select a folder, a file or an alias.
- Right-click on the selected item.
- Select Quick Actions.
- Depending on the macOS version, you may need to select Customize…, and turn on the Open Terminal in Folder Shortcut with a toggle switch.
- Launch the Open Terminal in Folder Shortcut.
macOS Privacy & Security Permissions
Section titled “macOS Privacy & Security Permissions”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.
When You Select a Folder
Section titled “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
Section titled “When You Select a File”If you select a file, Terminal will automatically open in the folder that contains that file.
When You Select a Finder Alias
Section titled “When You Select a Finder Alias”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
Section titled “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.
Customization
Section titled “Customization”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"
Folder Action Options
Section titled “Folder Action Options”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.
Alias Action Options
Section titled “Alias Action Options”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.
Troubleshooting
Section titled “Troubleshooting”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
Technical Notes
Section titled “Technical Notes”Terminal Launching Method
Section titled “Terminal Launching Method”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.
File Type Handling
Section titled “File Type Handling”- 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.
About This Shortcut
Section titled “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.
Current version: 1.2.1.