man openIf you use open programmatically (instead of interactively via a shell) then it helps to know the long forms of the options. You can list those by calling open without any arguments.
open
open .
open index.html
open -R index.html
open -a firefox index.html
open http://example.com
open 'mailto:joe@example.com?subject=Hi&body=Hi%20Joe!'Check [2] for details.
~/Library/Preferences/com.apple.LaunchServices.plistAn answer on Super User provides more information on what is going on here.
open has the following options for working with text editors:
open -e README.md
open -t README.md
open -fAnother example: open the text “Hello World!” in a new window.
echo 'Hello World!' | open -fOn my system, -f always used TextEdit, so your mileage may vary.
tell application "Google Chrome" tell tab 1 of window 1 to reload end tellTo execute that code on a Bash command line, type:
osascript <<-END tell application "Google Chrome" tell tab 1 of window 1 to reload end tell END
Example – changing the clipboard (e.g. if the current content of the clipboard is the plain text "Hello World", then it becomes "Hell- W-rld").
pbpaste | sed -e s/o/-/g | pbcopyExample – writing the clipboard to a text file:
pbpaste > file.txtExample – creating a bookmarklet: Take a JavaScript file, convert it to a single compact line via uglify.js, prepend the protocol "javascript:" and copy the resulting bookmarklet URL to the clipboard.
(echo -n "javascript:"; uglifyjs --no-copyright foo.js ; echo) | pbcopyThe option --no-copyright means that uglify.js will remove leading comments. One such comment might mention the above command, as a quick reference.