DEV Community


Open Terminal from Xcode

itscoderslife profile image Coder Originally published at on ・2 min read

I love Xcode as an IDE for macOS and iOS development. But it has its own set of limitations. One feature I miss a lot is Opening a Terminal window from the Xcode into the same directory of the project. This will save lots of time.

Every time you want to run a git command or cocoapods or say any xcode build command – Opening a Terminal manually and changing the directory to the project directory takes at the least 30 seconds to a minute. Now what if I say you can do this

Now, What if I say you can open a Terminal window and get to the project directory in 1 second or say with a shortcut key?

YES! One shortcut.

This is how you do it. It’s a one time setup.

  1. Create a 2 line shell script and give the file execute permission.
  2. Go to Xcode Preferences.
  3. Add a Behavior in Xcode. Name it and give a shortcut key.
  4. On the right side details pane check the Run option.
  5. From the adjacent drop-down menu choose the script you just saved in step 1.

Here’s the video on how to do it.


open -a Terminal "

Command to give execute permission:

chmod +x /path/to/the/

If you are lazy like me here’s the gist, download and use it:

Hope this is helpful.

Happy coding 😉

inspiration courtesy: The in-built Terminal of Visual Studio Code by Microsoft

-- Happy Coding :)

Discussion (9)

Editor guide
kisyov21 profile image
Ivaylo Kisyov • Edited

Thank you, I have managed to open the terminal but with a small change in the script. Single quotes are not visible in the script posted above. That is why I am attaching a screenshot of the script.

itscoderslife profile image
Coder Author

Yes. Thanks for the comment.

hvsw profile image
Henrique Valcanaia

Useful for me: to make it open in a new tab if already have a terminal instance running you can go to Dock preferences and set Prefer tabs when opening documents to Always.

itscoderslife profile image
Coder Author • Edited

Awesome 👏
Thanks for the hack 👍

kraci profile image
Jakub Kracina

Nice! but the script must be -> open -a Terminal "pwd"

tqos profile image
Bohdan Sasko

Thank you :) It's very useful article!

acsusanto profile image
Alexander Susanto

Its not working. It is showing an error.
Failed to launch script /Users/susanto/Desktop/ The operation couldn’t be completed. No such file or directory

itscoderslife profile image
Coder Author

Also make sure the script is copied and placed inside a file and place it in the "/Users/susanto/Desktop/" folder of your machine.

itscoderslife profile image
Coder Author

Hi Alexander

Please check the path to the script file.

You can also refer to the video here