VIS-MENU(1) | General Commands Manual | VIS-MENU(1) |
vis-menu
—
Interactively select an item from a list
vis-menu |
[-i ] [-t |
-b ] [-p
prompt] [-l
lines] [initial] |
vis-menu |
[-v ] |
vis-menu
allows a user to interactively
select one item from a list of options. A newline-separated list of items is
read from standard input, then the list of items is drawn directly onto the
terminal so the user may select one. Finally, the selected item is printed
to standard output.
For information on actually navigating the menu, see USAGE below.
-i
-t
|
-b
-t
is provided, the menu will always be drawn on
the top line of the terminal. When -b
is provided,
the menu will always be drawn on the bottom line.-p
prompt-l
lines-l
is provided, the list is displayed with each item on its own line,
lines lines high. If there are more than
lines items in the list, the user can scroll through
them with the arrow keys, just like in the regular horizontal mode.-v
vis-menu
prints its version number to standard
output and exits.vis-menu
displays the prompt (if any), a
text field, and a list of items. Normally these are presented side-by-side
in a single line, but if the -l
flag is given, the
prompt and typing area will be on the first line, and list items on the
following lines.
The following commands are available:
All other non-control characters will be inserted into the text field at the current cursor position.
When there is text in the text field, only list items that include the given text will be shown. If the text contains one or more spaces, each space-delimited string is a separate filter and only items matching every filter will be shown.
If the user filters out all the items from the list, then hits Enter to select the “currently highlighted” item, the text they typed will be returned instead.
Here's a shell-script that allows the user to choose a number from one to 10:
NUMBER=$(seq 1 10 | vis-menu -p "Choose a number") if [ $? -eq 0 ]; then echo "You chose: $NUMBER" else echo "You refused to choose a number, or an error occurred." fi
The vis-menu
utility exits 0 if the user
successfully selected an item from the list, and 1 if the user
cancelled.
If an internal error occurs, the vis-menu
utility prints a message to standard error and terminates with an exit
status greater than 1. Potential error conditions include being unable to
allocate memory, being unable to read from standard input, or being run
without a controlling terminal.
The original model for a single line menu reading items from
standard input was dmenu(1) which
implements the idea for X11. dmenu
is available from
http://tools.suckless.org/dmenu/
The code was subsequently re-worked for ANSI terminal output as
slmenu(1) which is available from
https://bitbucket.org/rafaelgg/slmenu/
Since slmenu
did not appear to be
maintained, it was forked to become vis-menu
to be
distributed with vis(1).
November 29, 2016 | Vis 0.9 |