terminal open
Due to using a Mac in a corporate environment where we were prevented from upgrading to Sierra (10.12.x) for what seems like forever, it's taken me a while to realize that an option to a command I used to use frequently on Leopard, Snow Leopard, Lion, Mountain Lion, Mavericks and finally El Capitan no longer exists in Sierra.
Frequently, I'd want/need to open the same locally generated web content in various browsers to test browser compatibility. Rather than open each browser and then use File > Open to browse to my file, I would use the Terminal utility and use this bash command to open the same file in multiple browsers.
for app in Safari Firefox.app Chrome.app; do open -a $app ~/Documents/some_web_page.html; done
The for loop would execute three commands:
open -a Safari ~/Documents/some_web_page.html
open -a Firefox.app ~/Documents/some_web_page.html
open -a Chrome.app ~/Documents/some_web_page.html
Which would result in 3 windows, one for each browser, opening the file ~/Documents/some_web_page.html
After upgrading to Sierra, when running the command 'open -a <app> <file>', I get this error:
open: invalid option -- 'a'
Usage: open [OPTIONS] -- command
This utility help you to start a program on a new virtual terminal (VT).
Options:
-c, --console=NUM use the given VT number;
-e, --exec execute the command, without forking;
-f, --force force opening a VT without checking;
-l, --login make the command a login shell;
-u, --user figure out the owner of the current VT;
-s, --switch switch to the new VT;
-w, --wait wait for command to complete;
-v, --verbose print a message for each action;
-V, --version print program version and exit;
-h, --help output a brief help message.
Why would Apple remove the ability to specify a non-default application to open a file? The ability to open web page using the non-default browser is a pain when using the GUI.
As an individual command entered into terminal:
open -a <application> <link>
seems to execute as expected;
see :
man open | more
Open works with Sierra just like it always did. Try 'man open'. You've probably mangled your path.
cdhw$ which open
/usr/bin/open
MacWilliams:~ cdhw$ open --help
open: unrecognized option `--help'
Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-s <partial SDK name>][-b <bundle identifier>] [-a <application>] [filenames] [--args arguments]
Help: Open opens files from a shell.
By default, opens each file using the default application for that file.
If the file is in the form of a URL, the file will be opened as a URL.
Options:
-a Opens with the specified application.
-b Opens with the specified application bundle identifier.
-e Opens with TextEdit.
[...]
The Apple /usr/bin/open command has not lost the -a option in my installations of El Capitan, Sierra, or High Sierra.
最后更新:2017-10-19 02:31:45
上一篇:
Need to convert PXM file without having to buy ...
下一篇:
Pathway to a folder via VPN
Macbook air as a hotspot
How to hide scuffs?
Why do I now have to babysit my podcasts
How do I get my money back on iTunes because of...
Cannot enter password for iCloud
Hi I am tryin to make a purchase for my kid on ...
I Forgot my icloud and now my iPhone stock on A...
All apps quit after upgrading to Sierra!
Blank screen on Mac Pro 2013 boot
Target Display Mode: Macbook Pro (2017) with iM...
相关内容
"com.apple.installer.pagecontroller error
any idea what error 3503 is?
Underallocation Detected on Main device
The operation couldn’t be completed. (BKA...
is ctoid.exe a virus on my ipad safari browser?
iTunes Error: Declined to authorize this image ...
Keep High Efficiency Original if Available Chec...
iTunes 12.7 cannot edit playlist
High Sierra Stuck & Decryption paused
Need to unlock iphone 5 to reactivate the phone...
热门内容
Christian Music Removed From Itunes
I'm being billed twice every month for Apple Mu...
iMac running slow
Fix disappearing album art after moving iTunes
Activation Locked iWatch
Can I change the iwatch to miles instead of kil...
I keep seeing the "You don't have permission to...
can't read any menus macbook air
iPad 2, iOs9.3, taking days to restore
charges made under itune memeberships