LinuxCommandLibrary

dialog

Display user-friendly dialog boxes from shell scripts

TLDR

Display a message

$ dialog --msgbox "[Message]" [height] [width]
copy

Prompt the user for text
$ dialog --inputbox "[Enter text:]" [8] [40] 2>[output.txt]
copy

Prompt the user for a yes/no question
$ dialog --yesno "[Continue?]" [7] [40]
copy

Display help
$ dialog
copy

SYNOPSIS

dialog [common-options] --widget-type [height width [height2] [datafile/items]]

PARAMETERS

--ascii-lines
    Draw lines using ASCII characters

--backtitle
    Title on screen top edge

--beep
    Beep on error actions

--beep-after
    Beep after successful actions

--calendar
    Calendar widget options

--checklist
    Checklist widget

--checklist-cols
    Checklist columns

--clear
    Clear screen before drawing

--clock
    Clock widget

--column-separator
    Checklist/radiolist column separator

--cr-cursor / --df-cursor
    Cursor after Enter/Tab

--create-rc
    Create sample config file

--dselect
    Directory selector

--editbox
    Editable textbox

--fselect
    File selector

--fixed-font
    Assume fixed font (disables wrapping)

--form
    Form widget

--help
    Show help

--help-btn
    Enable help button

--help-file
    Help file

--help-label
    Help button label

--help-line
    F1 help line

--help-tags
    Use tags in help file

--infobox
    Informational box

--input-fd
    Input file descriptor

--inputbox []
    Input box

--item-help
    Show item help

--keep-tite
    Keep terminal init

--keep-window
    Keep window size

--license
    Show license

--max-input
    Max input length

--menu
    Menu widget

--msgbox
    Message box

--msgbox
    Message box

--nocancel
    Disable cancel button

--output-fd
    Output file descriptor

--passwordbox / --passwordform
    Password input variants

--print-maxsize
    Print max window size

--print-size
    Print proposed window size

--print-version
    Print version

--progressbox
    Progress box

--radiolist
    Radiolist widget

--rc-file
    Read config file

--scrollbar
    Draw scrollbar

--separate-output
    Print output separately

--separate-widget
    Separate widget output

--smooth
    Smooth scrollbar

--stdout
    Use stdout

--tab-correct
    Tab converts to space

--tailbox
    Tailbox widget

--tailboxbg
    Background tailbox

--textbox
    Scrollable textbox

--timeout
    Auto-close after seconds

--title
    Box title

--trim
    Trim whitespace

--version
    Show version

--visit
    Visit widgets without exiting

--yesno
    Yes/no box

DESCRIPTION

The dialog command is a versatile utility for creating interactive dialog boxes in text terminals using the ncurses library. It enables shell scripts and programs to present user-friendly interfaces without graphical dependencies, ideal for installers, configurators, and TUIs. Key features include widgets for messages, input, menus, checklists, radiobuttons, forms, progress bars, file/directory selectors, calendars, and clocks. Common customizations cover titles, backtitles, timeouts, beeps, whitespace trimming, ASCII lines, scrollbars, and multi-column layouts. It supports help integration, item-specific help, and output to stdout or files. User interactions return standardized exit codes: 0 (OK), 1 (cancel), 3 (ESC), 4 (error), 122 (resize), 255 (suspend). Widely used in distributions like Debian installers and tools like debconf, it ensures consistent behavior across terminals while handling resizing and keyboard navigation gracefully.

CAVEATS

Limited to text terminals; requires ncurses; no mouse support by default; complex layouts may wrap poorly on small screens; UTF-8 support varies by terminal.

EXIT CODES

0: OK/Yes; 1: Cancel/No; 3: ESC; 4: Error; 5: Extra key; 122: Window resize; 255: Suspend (Ctrl+Z)

EXAMPLE USAGE

dialog --title "Confirm" --yesno "Continue?" 5 20
echo $? # Check exit code

CONFIG FILE

~/.dialogrc or /etc/dialogrc for defaults like use_colors, screen_colors

HISTORY

Developed by Savio Lam in 1994 as a Perl script, rewritten in C by Vincent Batts. Maintained by Thomas E. Dickey since 1999, closely tied to ncurses development. Version 1.3-20240224 is current, used extensively in Linux distro installers like Debian's debconf.

SEE ALSO

whiptail(1), ncurses(3), newt(3), zenity(1), dialogrc(5)

Copied to clipboard