open
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
- man 1 'open' [EN]
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.
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
for profile in 'alex' 'marty'; do
open -a 'Firefox' -n --args -private -P "${profile}"
done
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
- ↑ man 1 'open'