What is open-cli?
The open-cli npm package allows you to open files, URLs, or applications using the command line. It is a simple and efficient tool for automating the opening of various resources directly from the terminal.
What are open-cli's main functionalities?
Open a URL
This feature allows you to open a URL in the default web browser. The code sample demonstrates how to open Google's homepage.
open-cli 'https://www.google.com'
Open a file
This feature allows you to open a file with the default application associated with its file type. The code sample demonstrates how to open a text file located at a specific path.
open-cli './path/to/file.txt'
Open an application
This feature allows you to open an application by its name. The code sample demonstrates how to open the Calculator application.
open-cli 'Calculator'
Other packages similar to open-cli
opn
The opn package is similar to open-cli in that it allows you to open files, URLs, or applications from the command line. However, opn is more focused on being a programmatic API for opening things, whereas open-cli is more command-line oriented.
open
The open package is another alternative that provides similar functionality. It is a more modern and actively maintained package compared to opn. It also offers more options and flexibility for opening files, URLs, or applications.
open-cli
Open stuff like URLs, files, executables. Cross-platform.
Install
npm install --global open-cli
Usage
$ open-cli --help
Usage
$ open-cli <file|url> [--wait] [--background] [-- <app> [args]]
$ cat <file> | open-cli [--extension] [--wait] [--background] [-- <app> [args]]
Options
--wait Wait for the app to exit
--background Do not bring the app to the foreground (macOS only)
--extension File extension for when stdin file type cannot be detected
Examples
$ open-cli https://sindresorhus.com
$ open-cli https://sindresorhus.com -- firefox
$ open-cli https://sindresorhus.com -- 'google chrome' --incognito
$ open-cli unicorn.png
$ cat unicorn.png | open-cli
$ echo '<h1>Unicorns!</h1>' | open-cli --extension=html
The following file types are automagically detected when using stdin mode.
Related
- open - API for this module