Page
Library
Module
Module type
Parameter
Class
Class type
Source
Conveniently open files such as PDFs in their default applications straigt from OCaml.
You can install the library using opam:
$ opam install openThen in utop or ocaml,
$ ocaml
> #require "open";;
> Open.in_default_app "/home/steffen/ocaml.svg";;
- : bool = true
// SVG viewer opens and displays ocaml.svgThe boolean returned by Open.in_default_app indicates whether the open command exited normally:
> Open.in_default_app "/path/to/non-existent.file";;
- : bool = false
// nothing happensBoth absolute and relative paths are supported:
> Open.in_default_app ".";;
- : bool = true
// file manager displays current working directoryThe tiny API is documented here.
The library requires dune (formerly known as jbuilder) to build, but has no other dependencies.
Run make to build and make test to see the library in action. This should open several files from the examples/basic folder.
There is also a more sophisticated example in examples/graphviz that requires graphivz and Jane Street's core (version v0.9.0 or higher). You can build & run it as follows:
jbuilder build @graphvizThe library has been tested under Linux, MacOS, and Cygwin. There is experimental support for native Windows, but this is untested. The implementation uses
xdg-open on Linuxopen on MacOScygstart on Cygiwn, andcmd start on Windows.Suggestions and contributions are always welcome. Feel free to submit pull requests.