The Mac OS X shell has several Mac-only commands for communicating with the graphical user interface (GUI). They are useful in three cases: First, when switching back and forth between shell and GUI. Second, when interacting with the system from a language that is not Objective C or AppleScript: Bash, Node.js , Python etc.
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 -R index.html
open -a firefox index.html
open 'mailto:email@example.com?subject=Hi&body=Hi%20Joe!'Check  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: