Bash powered interactive interfaces.
Go to file
2021-08-25 18:31:43 +03:00
images init 2021-08-25 18:31:43 +03:00
lib init 2021-08-25 18:31:43 +03:00
checklist.sh init 2021-08-25 18:31:43 +03:00
LICENSE.md init 2021-08-25 18:31:43 +03:00
menu.sh init 2021-08-25 18:31:43 +03:00
messagebox.sh init 2021-08-25 18:31:43 +03:00
README.md init 2021-08-25 18:31:43 +03:00
yesno.sh init 2021-08-25 18:31:43 +03:00

Interact — Bash powered interactive interfaces

Interact — is Bash functions library that implements some interactive elements like menus, checkboxes and others.

You can use Interact instead of Whiptail and Dialog. Interact depends only Bash native commands and basic utils.

Usage

Clone lib/interact.bash in your project and source it:

source lib/*

# do something

Functions

menu

Simple menu. Returns string with an item as SELECTED_ITEM. Navigation keys: HJKL (vim-style), arrow keys and [, ].

menu

Usage:

menu "${array[@]}"
echo "$SELECTED_ITEM"

Demo script: menu.sh.

You can override default help text and prompt via variables:

MENU_PROMPT   -- string with prompt message;
MENU_INDENT   -- string with intentation chars;
MENU_HELP     -- string with help message.

checklist

Checklist. Returns array of checked items as CHECKED_ITEMS. Mostly same as menu, but needed changes. Features: automove to next item, check/uncheck items, variables supported too.

checklist

Syntax:

checklist "${array[@]}"
echo "${CHECKED_ITEMS[@]}"

Demo script: checklist.sh.

Varisables:

CHECK_PROMPT -- string with prompt message;
CHECK_INDENT -- string with intentation chars;
CHECK_HELP   -- string with help message.

messagebox

Just screen with text message. Press any key to close it.

Usage:

MSGBOX_TITLE='My title'
messagebox 'My message'

Demo script: messagebox.sh.

Varisbles:

MSGBOX_TITLE    -- title (centered and bold);
MSGBOX_WIDTH    -- terminal width. Default: 75 cols;
MSGBOX_HELP     -- help message.

yesno

Yes/No dialog. You can type Y or N or select item in menu.

Usage:

if yesno "Question?\n"; then
  do_something
else
  do_nothing
fi

Demo script: yesno.sh.

Variables:

ASSUME_YES  -- skip dialog, return "Yes";
YN_INDENT   -- indent;
YN_HELP     -- help text.

License

MIT License :)