Skip to content

Commit

Permalink
Merge pull request #2 from triplef/master
Browse files Browse the repository at this point in the history
Added flag to open using default application
  • Loading branch information
macecchi committed Oct 16, 2018
2 parents b7df726 + 4076ce3 commit 5899522
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ You can also use the flag `--beta` or simply `-b` to open the project using Xcod
xcopen --beta /path/to/MyAwesomeApp/
```

Finally, specifying `--default` or `-d` will open the project with the default application:

```bash
xcopen --beta /path/to/MyAwesomeApp/
```

This can be useful if your Xcode installations contain a version number (e.g. when using [xcode-install](https://github.com/KrauseFx/xcode-install)), in which case the first two options will not work.


## License

Expand Down
19 changes: 14 additions & 5 deletions xcopen
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
# Default options
DIR="."
DEFAULT=false
BETA=false

# Usage
USAGE="Usage: $0 [-b|--beta] [PATH]"
USAGE="Usage: $0 [-d|--default] [-b|--beta] [PATH]"

# Parse arguments
while [ $# -gt 0 ]
Expand All @@ -15,6 +16,10 @@ do
echo "$USAGE"
exit
;;
-d|--default)
DEFAULT=true
shift
;;
-b|--beta)
BETA=true
shift
Expand All @@ -34,15 +39,19 @@ shopt -s nullglob

FOUND=0
if [ $BETA = false ]; then
APP="Xcode"
if [ $DEFAULT = false ]; then
APP="-a Xcode"
else
APP=""
fi
else
APP="Xcode-beta"
APP="-a Xcode-beta"
fi

# Try to open the first xcworkspace file found
EXT='xcworkspace'
for i in $DIR/*.$EXT; do
open -a $APP "$i"
open $APP "$i"
FOUND=1
break
done
Expand All @@ -51,7 +60,7 @@ done
if [ $FOUND -eq 0 ]; then
EXT='xcodeproj'
for i in $DIR/*.$EXT; do
open -a $APP "$i"
open $APP "$i"
FOUND=1
break
done
Expand Down

0 comments on commit 5899522

Please sign in to comment.