Bash powered interactive interfaces.
Go to file
gd 9d9730fbeb update README 2021-08-28 11:09:07 +03:00
images init 2021-08-25 18:31:43 +03:00
lib init 2021-08-25 18:31:43 +03:00
LICENSE.md init 2021-08-25 18:31:43 +03:00
README.md update README 2021-08-28 11:09:07 +03:00
checklist.sh 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
yesno.sh init 2021-08-25 18:31:43 +03:00

README.md

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.

WARN: interact is under development and can be used for testing purposes only. Possible changes soon that will break backward compatibility with the current version of the code. You can wait for the stable version of the library or fork it.

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 :)