DevDungeon
- Labs
Knowledge
Social
DevDungeon
Knowledge
Social
This is an old revision of the document!
Dialog is a script-driven menu and text interface generation tool. For example, it has file pickers, menus, checklists, confirmations, calendars, progress bars, etc.
The official documentation and downloads are at https://invisible-island.net/dialog/#documentation.
More screenshots and examples of all widgets are available at https://invisible-island.net/dialog/dialog-figures.html.
In Debian and most Linux distributions it's as simple as using the package manager to install:
apt install dialog dpkg -L dialog dialog --version dialog --help man dialog
If you want to build from source, simply download, configure, and make:
wget ftp://ftp.invisible-island.net/dialog/dialog.tar.gz tar xzf dialog.tar.gz cd dialog-1.3-20210324 # Or whatever it is ./configure --help | less # Check options ./configure make ./dialog --version ./dialog --help make install # optional
Here is an example of a menu with a list of choices:
# Generate a menu dialog --menu "Open mail" 20 40 10 \ "Account 1" "~/.muttrc.1" "Account 2" "~/.muttrc.2" \ 2>answer.txt # answer.txt will contain 'Account 1' or 'Account 2'
Here is another example that shows how to get output a different way. This is out it is done in the examples in the source code.
# Create temp stream for current shell exec 3>&1 # Prompt with dialog and get response user_text=$(dialog --inputbox Testing 0 0 2>&1 1>&3) # Store return value of dialog process. 0 = success. # Check if it's 0 to confirm they didn't cancel exit_code=$? # Close the temp stream exec 3>&- # Print the results Echo "Program exit code: $exit_code" echo "User input: $user_text"
Below you will find a list of all the options and menus available. Also refer to https://invisible-island.net/dialog/dialog-figures.html for screenshots and examples of all widgets.
There are also numerous script examples in the source code in a directory called samples/
$ dialog --help cdialog (ComeOn Dialog!) version 1.2-20130523 Copyright 2000-2012,2013 Thomas E. Dickey This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * Display dialog boxes from shell scripts * Usage: dialog <options> { --and-widget <options> } where options are "common" options, followed by "box" options Special options: [--create-rc "file"] Common options: [--ascii-lines] [--aspect <ratio>] [--backtitle <backtitle>] [--beep] [--beep-after] [--begin <y> <x>] [--cancel-label <str>] [--clear] [--colors] [--column-separator <str>] [--cr-wrap] [--date-format <str>] [--default-button <str>] [--default-item <str>] [--defaultno] [--exit-label <str>] [--extra-button] [--extra-label <str>] [--help-button] [--help-label <str>] [--help-status] [--hfile <str>] [--hline <str>] [--ignore] [--input-fd <fd>] [--insecure] [--item-help] [--keep-tite] [--keep-window] [--last-key] [--max-input <n>] [--no-cancel] [--no-collapse] [--no-cr-wrap] [--no-items] [--no-kill] [--no-label <str>] [--no-lines] [--no-mouse] [--no-nl-expand] [--no-ok] [--no-shadow] [--no-tags] [--nook] [--ok-label <str>] [--output-fd <fd>] [--output-separator <str>] [--print-maxsize] [--print-size] [--print-version] [--quoted] [--scrollbar] [--separate-output] [--separate-widget <str>] [--shadow] [--single-quoted] [--size-err] [--sleep <secs>] [--stderr] [--stdout] [--tab-correct] [--tab-len <n>] [--time-format <str>] [--timeout <secs>] [--title <title>] [--trace <file>] [--trim] [--version] [--visit-items] [--yes-label <str>] Box options: --buildlist <text> <height> <width> <tag1> <item1> <status1>... --calendar <text> <height> <width> <day> <month> <year> --checklist <text> <height> <width> <list height> <tag1> <item1> <status1>... --dselect <directory> <height> <width> --editbox <file> <height> <width> --form <text> <height> <width> <form height> <label1> <l_y1> <l_x1> <item1> <i_y1> <i_x1> <flen1> <ilen1>... --fselect <filepath> <height> <width> --gauge <text> <height> <width> [<percent>] --infobox <text> <height> <width> --inputbox <text> <height> <width> [<init>] --inputmenu <text> <height> <width> <menu height> <tag1> <item1>... --menu <text> <height> <width> <menu height> <tag1> <item1>... --mixedform <text> <height> <width> <form height> <label1> <l_y1> <l_x1> <item1> <i_y1> <i_x1> <flen1> <ilen1> <itype>... --mixedgauge <text> <height> <width> <percent> <tag1> <item1>... --msgbox <text> <height> <width> --passwordbox <text> <height> <width> [<init>] --passwordform <text> <height> <width> <form height> <label1> <l_y1> <l_x1> <item1> <i_y1> <i_x1> <flen1> <ilen1>... --pause <text> <height> <width> <seconds> --prgbox <text> <command> <height> <width> --programbox <text> <height> <width> --progressbox <text> <height> <width> --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>... --rangebox <text> <height> <width> <min-value> <max-value> <default-value> --tailbox <file> <height> <width> --tailboxbg <file> <height> <width> --textbox <file> <height> <width> --timebox <text> <height> <width> <hour> <minute> <second> --treeview <text> <height> <width> <list-height> <tag1> <item1> <status1> <depth1>... --yesno <text> <height> <width> Auto-size with height and width = 0. Maximize with height and width = -1. Global-auto-size if also menu_height/list_height = 0.
You can specify settings in a ~/.dialogrc
file. There might also be one in your system under /etc/dialogrc
.
To generate a default rc file, run the following command.
# Create a ~/.dialogrc file dialog --create-rc ~/.dialogrc
Then you'll have an rc file with all the color and options populated for you to modify.
If you want to see some example rc files, check in the source code in a directory called samples/
. For example whiptail.rc
. Screenshots are available at https://invisible-island.net/dialog/dialog-figures.html#list_colors.
To override the default rc filename, set a DIALOGRC
environment variable to specify the file you want to use.