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

> Learn how to add an Open in Terminal button to the macOS Finder toolbar using an Automator app that runs AppleScript to cd into the current folder.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2023-01-29 | Topics: [Mac](https://flaviocopes.com/tags/mac/) | Canonical: https://flaviocopes.com/how-to-add-an-open-in-terminal-icon-in-macos-finder/

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:

![macOS Finder window showing an Open in Terminal button in the toolbar](https://flaviocopes.com/images/how-to-add-an-open-in-terminal-icon-in-macos-finder/1.webp)

Here’s how you can do that too.

Open Automator. Pick “Application”

![Automator application window with Application template selected](https://flaviocopes.com/images/how-to-add-an-open-in-terminal-icon-in-macos-finder/2.webp)

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

```javascript
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
```

![Automator showing Run AppleScript action with the terminal opening script code](https://flaviocopes.com/images/how-to-add-an-open-in-terminal-icon-in-macos-finder/3.webp)

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

```shell
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
'
```

![Automator showing Run Shell Script action as an alternative to AppleScript](https://flaviocopes.com/images/how-to-add-an-open-in-terminal-icon-in-macos-finder/4.webp)

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

```shell
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.

![Get Info dialog showing how to change the app icon by dragging from Terminal app](https://flaviocopes.com/images/how-to-add-an-open-in-terminal-icon-in-macos-finder/5.webp)

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

![Dragging the app to Finder toolbar while holding Command key to add the button](https://flaviocopes.com/images/how-to-add-an-open-in-terminal-icon-in-macos-finder/6.webp)

That’s it!
