Skip to content

Commit 5899522

Browse files
authored
Merge pull request #2 from triplef/master
Added flag to open using default application
2 parents b7df726 + 4076ce3 commit 5899522

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ You can also use the flag `--beta` or simply `-b` to open the project using Xcod
4545
xcopen --beta /path/to/MyAwesomeApp/
4646
```
4747

48+
Finally, specifying `--default` or `-d` will open the project with the default application:
49+
50+
```bash
51+
xcopen --beta /path/to/MyAwesomeApp/
52+
```
53+
54+
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.
55+
4856

4957
## License
5058

xcopen

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/bin/bash
22
# Default options
33
DIR="."
4+
DEFAULT=false
45
BETA=false
56

67
# Usage
7-
USAGE="Usage: $0 [-b|--beta] [PATH]"
8+
USAGE="Usage: $0 [-d|--default] [-b|--beta] [PATH]"
89

910
# Parse arguments
1011
while [ $# -gt 0 ]
@@ -15,6 +16,10 @@ do
1516
echo "$USAGE"
1617
exit
1718
;;
19+
-d|--default)
20+
DEFAULT=true
21+
shift
22+
;;
1823
-b|--beta)
1924
BETA=true
2025
shift
@@ -34,15 +39,19 @@ shopt -s nullglob
3439

3540
FOUND=0
3641
if [ $BETA = false ]; then
37-
APP="Xcode"
42+
if [ $DEFAULT = false ]; then
43+
APP="-a Xcode"
44+
else
45+
APP=""
46+
fi
3847
else
39-
APP="Xcode-beta"
48+
APP="-a Xcode-beta"
4049
fi
4150

4251
# Try to open the first xcworkspace file found
4352
EXT='xcworkspace'
4453
for i in $DIR/*.$EXT; do
45-
open -a $APP "$i"
54+
open $APP "$i"
4655
FOUND=1
4756
break
4857
done
@@ -51,7 +60,7 @@ done
5160
if [ $FOUND -eq 0 ]; then
5261
EXT='xcodeproj'
5362
for i in $DIR/*.$EXT; do
54-
open -a $APP "$i"
63+
open $APP "$i"
5564
FOUND=1
5665
break
5766
done

0 commit comments

Comments
 (0)