open

From RaySoft

The open command opens a file (or a directory or URL), just as if you had double-clicked the file's icon. If no application name is specified, the default application as determined via 'LaunchServices' is used to open the specified files.[1]

Documentation

Syntax

open [PARAMETER ...] [FILE ...] [--args PARAMETER ...]

Parameters

-a <APPLICATION>
Specifies the APPLICATION to use for opening the file.
--args <ARGUMENTS>
All remaining ARGUMENTS are passed to the opened application in the argv parameter to main().
NOTE:
These arguments are not opened or interpreted by the open tool.
-g
Do not bring the application to the foreground.
-j
Launches the app hidden.
-n
Open a new instance of the application(s) even if one is already running.
-R
Reveals the file(s) in the Finder instead of opening them.
-W
Causes open to wait until the applications it opens (or that were already open) have exited.

Examples

Test if applications are installed
for app in 'Firefox' 'Joplin'; do
  if open -a "${app}" -R >'/dev/null' 2>&1; then
    echo "The application '${app}' is installed!"
  fi
done
Start multiple Firefox instances with different profiles using open on macOS
for profile in 'alex' 'marty'; do
  open -a 'Firefox' -n --args -private -P "${profile}"
done
Start multiple Chrome instances with different profiles using open on macOS
app_config_dir="${HOME}/Library/Application Support/Google/Chrome"

for profile in 'alex' 'marty'; do
  open -a 'Google Chrome' -n --args --incognito \
    --profile-directory="${app_config_dir}/${profile}"
done

References

  1. man 1 'open'