Adds option for directory to Xcode xc function. (#5253)
Diff
1diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md
2index 15e65785905ff2c58024bb54229904f86432a561..c12ce047fe51115b6ecda93c36883fb4539ff08b 100644
3--- a/plugins/xcode/README.md
4+++ b/plugins/xcode/README.md
5@@ -26,7 +26,7 @@ plugins=(... xcode)
6 7 ### `xc`
8 9-Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory.
10+Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. You can also specify a directory to look in for the Xcode files.
11 Returns 1 if it didn't find any relevant files.
1213 ### `simulator`
14diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh
15index 0a2fa0839bdb99832f7d7eb4899959def7044002..f711c39fb6237e8b950ecbb9ca433afc7e2ebf51 100644
16--- a/plugins/xcode/xcode.plugin.zsh
17+++ b/plugins/xcode/xcode.plugin.zsh
18@@ -7,10 +7,19 @@ alias xcsel='sudo xcode-select --switch'
19 # source: http://gist.github.com/subdigital/5420709
20 function xc {
21 local xcode_proj
22- xcode_proj=(*.{xcworkspace,xcodeproj}(N))
23+ if [[ $# == 0 ]]; then
24+ xcode_proj=(*.{xcworkspace,xcodeproj}(N))
25+ else
26+ xcode_proj=($1/*.{xcworkspace,xcodeproj}(N))
27+ fi
28+
2930 if [[ ${#xcode_proj} -eq 0 ]]; then
31- echo "No xcworkspace/xcodeproj file found in the current directory."
32+ if [[ $# == 0 ]]; then
33+ echo "No xcworkspace/xcodeproj file found in the current directory."
34+ else
35+ echo "No xcworkspace/xcodeproj file found in $1."
36+ fi
37 return 1
38 else
39 echo "Found ${xcode_proj[1]}"