From 0d60bdd1dd8f1bb62337aaed7eff9cdb190c1623 Mon Sep 17 00:00:00 2001 From: John Regner Date: Mon, 22 Feb 2016 09:36:54 -0800 Subject: [PATCH] Handle fallback if Xcode is not installed If Xcode is not installed the active_path = /Library/Developer/CommandLineTools Thus if the active_path does not contain the word Xcode, we will fall back to opening the project file with the Finder's recommended program --- plugins/xcode/xcode.plugin.zsh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index a7912926..a617eed1 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -15,8 +15,13 @@ function xc { else echo "Found ${xcode_proj[1]}" active_path=$(xcode-select -p) - active_path=${active_path%%/Contents/Developer*} - open -a "${active_path}" "${xcode_proj[1]}" + if [[ ${active_path} =~ "Xcode" ]]; then + active_path=${active_path%%/Contents/Developer*} + echo "Opening with ${active_path}" + open -a "${active_path}" "${xcode_proj[1]}" + else # No Xcode installed + open "${xcode_proj[1]}" # Fall back to using Finder suggested application + fi fi }