Dialog adds dialog boxes to shell scripts, providing such things as menus, input boxes and even calendars. This uses TABS and arrows to move about, and sometimes keyboard style h,j,k,l. The calendar returns Day/Month/Year, which could trip up American users.
Here's a simple calendar:
result=`dialog --stdout --title "CALENDAR" --calendar "Please choose a date..." 0 0` clear echo $result
That will let you select a date from a calendar displayed on the screen.
A progress gauge:
files=`ls -l | wc -l` copied=1 ( while [ $files -gt $copied ] do pct=$((100 * copied / $files)) echo $pct copied=$((copied + 1)) sleep 1 done ) | dialog --title "Files tested" --gauge "" 5 30
That shows a gauge that changes as the script runs.
You can find more examples at https://www.fifi.org/doc/dialog/examples
Got something to add? Send me email.
More Articles by Tony Lawrence © 2012-07-17 Tony Lawrence
The object-oriented model makes it easy to build up programs by accretion. What this often means, in practice, is that it provides a structured way to write spaghetti code. (Paul Graham)