Skip to content

How to add an “Open in Terminal” icon in macOS Finder

New Course Coming Soon:

Get Really Good at Git

Let’s say I’m in the Finder, I open a folder and I want to open it in the Terminal.

I decided to make it easy by adding an “Open in Terminal” icon in the Finder:

Here’s how you can do that too.

Open Automator. Pick “Application”

Search for “Run AppleScript” in the list of actions, and paste these lines:

on run {input, parameters}
	
	tell application "Finder"
		set myPath to (POSIX path of (target of front window as alias))
	end tell
	
	tell application "Terminal"
		do script "cd " & myPath
		activate
	end tell
	
	return input
end run

If you prefer you can use “Run Shell Script” instead, and write this bash script:

osascript -e '
tell application "Finder"
	set myPath to (POSIX path of (target of front window as alias))
end tell
	
tell application "Terminal"
	do script "cd " & myPath
	activate
end tell
'

The first runs osascript (which is a script to run AppleScript) with the following AppleScript

tell application "Finder"
	set myPath to (POSIX path of (target of front window as alias))
end tell

which basically gets the current opened folder absolute path and stores it to the myPath variable.

Then we open the Terminal app and we run the cd command to go into that folder.

Save this application in the Applications folder and then click Get Info to change its icon.

You can open Get info on the Terminal app in the Utilities folder, and drag its icon to the top-left small icon to assign that icon to our new little app.

Finally keep the ⌘ command key pressed and drag the app in the Finder toolbar.

That’s it!

Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. A course that helps you feel less frustrated with Git. Launching May 21, 2024. Join the waiting list!

Here is how can I help you: