You can make Xcode automatically open a terminal at the current directory using a shortcut you specify. Here are the steps:
- create an empty shell scrip file with the name
open_terminal.sh
and paste the following content in it:
#!/bin/bash
# I mainly use this as a behavior in Xcode to open
# Terminal at the project's working directory.
open -a Terminal "`pwd`"
# Optional script to make the opened window fullscreen.
# you can delete it if you don't want fullscreen.
# make sure to read step 2 bellow to make it work.
osascript <<EOD
tell application "System Events" to tell process "Terminal"
delay 0.75
set value of attribute "AXFullScreen" of window 1 to true
end tell
EOD
-
Optional step: If you want to run the optional script and allow terminal to open in fullscreen, give Xcode access to accessibility features from System Preferences > Security & Privacy > Privacy > Accessibility > + > locate and select Xcode.
-
From Xcode: Go to Preferences > Behaviors and click the + icon to create a custom behavior.
-
give it a name, for example: "Open Terminal"
-
Optionally give the behavior a shortcut.
-
Check the Run box and click "Choose Script..." in the dropdown menu.
-
locate the shell script file you created and select it.
-
If the shell script file can't be selected, open a terminal in the directory where the file is located and run the following command:
chmod +x open_terminal.sh
then try to select the file again.
- You can now trigger the behavior by using your shortcut or from the menubar under Xcode > Behaviors.
That's it! you now have an Xcode behavior to make your life easy :)
p.s. If the fullscreen script doesn't work try modifying the delay from 0.75 to a longer interval to give time for the terminal window to launch before attempting to make it fullscreen.