Skip to content

Instantly share code, notes, and snippets.

@gauravkeshre
Last active January 15, 2019 13:45
Show Gist options
  • Save gauravkeshre/28a65b0bd7eddc1f78ae58e4ca5fb2f6 to your computer and use it in GitHub Desktop.
Save gauravkeshre/28a65b0bd7eddc1f78ae58e4ca5fb2f6 to your computer and use it in GitHub Desktop.
Launch terminal and CD into the current project directory.

Launch Terminal and open Xcode project directory in that

Add New Behavior
  1. Launch Xcode > Preferences > Behaviors
  2. + to add
  3. Rename "New Behavior" to something more meaningful "Launch Terminal"
Key Binding
  1. Tap on ⌘ opposite to Behavior name
  2. Choose a handy (non-conflicting) key binding. I use Control + Command + t (⌃⌘T)
Configure the run action
  1. Save the LaunchProjectInTerminal.sh so somewhere safe and accessible.
  2. In the details panel of the new behavior, look for the checkmark Run and check it.
  3. Select "Choose Script" and provide the path to the LaunchProjectInTerminal.sh file
Done
# This script
# 1. takes the current project path.
# 2. Launches Terminal.
# 3. CD to current project path.
#!/bin/sh
set -e
if [ -n "$XcodeProjectPath" ]; then
open -a Terminal "$XcodeProjectPath"/..
else
open -a Terminal "$XcodeWorkspacePath"/..
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment