.Dd November 29, 2016
.Dt VIS-OPEN 1
.Os Vis VERSION
.Nd Interactively select a file to open
.Op Fl p Ar prompt
.Op Fl f
.Op Ar --
.Op Ar files
.Fl h |
takes a list of filenames and directories on the command-line
and displays them in a menu for the user to select one.
If the user selects a directory
.Li .. ) ,
the directory contents are displayed as a fresh menu.
Once the user has selected a filename,
its absolute path is printed to standard output.
.Xr vis-menu 1
as its user-interface,
so see that page for more details.
.Bl -tag -width flag
.It Fl p Ar prompt
before the list of items.
This is passed straight through to
.Xr vis-menu 1 .
.It Fl f
is provided with a single filename or directory argument,
it will automatically select it
(printing the filename to standard output,
or presenting a new menu with the contents of the directory).
will always present the arguments it's given,
even if there's only one.
.It Fl -
If this token is encountered before the first non-option argument,
all following arguments will be treated as menu-items,
even if they would otherwise be valid command-line options.
If encountered after the first non-option argument,
or after a previous instance of
it is treated as a menu-item.
.It Ar files
File and directory names to be presented to the user.
If a name does not exist on the filesystem
and the user selects it,
it is treated as a file.
.It Fl h | Fl -help
prints a usage summary and exits,
ignoring any other flag and arguments.
.Sh EXIT STATUS
.Ex -std vis-open
.Xr vis-menu 1 ,
prints nothing and sets its exit status to 1
if the user refused to select a file.
.Bd -literal -offset indent
CHOICE=$(vis-open -p "Select a file to stat")
if [ $? -gt 0 ]; then
echo "No selection was made, or an error occurred"
.Sh SEE ALSO
.Xr vis 1 ,
.Xr vis-menu 1
.Xr ls 1
to obtain the contents of a directory,
weird things might happen if you have control-characters in your filenames.