summaryrefslogtreecommitdiff
path: root/plugins/xcode
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/xcode')
-rw-r--r--plugins/xcode/README.md8
-rw-r--r--plugins/xcode/xcode.plugin.zsh35
2 files changed, 35 insertions, 8 deletions
diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md
index 15e657859..37f882638 100644
--- a/plugins/xcode/README.md
+++ b/plugins/xcode/README.md
@@ -19,16 +19,20 @@ plugins=(... xcode)
| xcdd | Purge all temporary build information | rm -rf ~/Library/Developer/Xcode/DerivedData/* |
| xcp | Show currently selected Xcode directory | xcode-select --print-path |
| xcsel | Select different Xcode directory by path | sudo xcode-select --switch |
-
+| xx | Opens the files listed in Xcode | open -a "Xcode.app" |
## Functions
### `xc`
-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.
+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.
Returns 1 if it didn't find any relevant files.
+### `xx`
+
+Opens the files listed in Xcode, multiple files are opened in a multi-file browser.
+
### `simulator`
Opens the iOS Simulator from your command line, dependent on whichever is the active developer directory for Xcode. (That is, it respects the `xcsel` setting.)
diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh
index 0a2fa0839..89703fe3c 100644
--- a/plugins/xcode/xcode.plugin.zsh
+++ b/plugins/xcode/xcode.plugin.zsh
@@ -4,18 +4,41 @@ alias xcp='xcode-select --print-path'
alias xcsel='sudo xcode-select --switch'
# original author: @subdigital
-# source: http://gist.github.com/subdigital/5420709
+# source: https://gist.github.com/subdigital/5420709
function xc {
local xcode_proj
- xcode_proj=(*.{xcworkspace,xcodeproj}(N))
+ if [[ $# == 0 ]]; then
+ xcode_proj=(*.{xcworkspace,xcodeproj}(N))
+ else
+ xcode_proj=($1/*.{xcworkspace,xcodeproj}(N))
+ fi
+
if [[ ${#xcode_proj} -eq 0 ]]; then
- echo "No xcworkspace/xcodeproj file found in the current directory."
+ if [[ $# == 0 ]]; then
+ echo "No xcworkspace/xcodeproj file found in the current directory."
+ else
+ echo "No xcworkspace/xcodeproj file found in $1."
+ fi
return 1
else
- echo "Found ${xcode_proj[1]}"
- open "${xcode_proj[1]}"
+ local active_path
+ active_path=$(xcode-select -p)
+ active_path=${active_path%%/Contents/Developer*}
+ echo "Found ${xcode_proj[1]}. Opening with ${active_path}"
+ open -a "$active_path" "${xcode_proj[1]}"
+ fi
+}
+
+# Opens a file or files in the Xcode IDE. Multiple files are opened in multi-file browser
+# original author: @possen
+function xx {
+ if [[ $# == 0 ]]; then
+ echo "Specify file(s) to open in xcode."
+ return 1
fi
+ echo "${xcode_files}"
+ open -a "Xcode.app" "$@"
}
# "XCode-SELect by Version" - select Xcode by just version number
@@ -61,7 +84,7 @@ function xcselv {
function _omz_xcode_print_xcselv_usage {
cat << EOF >&2
-Usage:
+Usage:
xcselv <version>
xcselv [options]