Changing colours in whiptail

Viewed 5969

Is there any way to change particular colour in whiptail ?

For example to mark specific text in red ?

For example :

#!/bin/bash
window=$(stty -a | tr \; \\012 |egrep 'rows|columns' | cut '-d ' -f3)
RED="red"
GREEN="green"


OPTION=$(whiptail --menu "\n\n\n\n\n\n\n\n" --title  "menu" --nocancel $window 20 \
"1" "COLOUR IS $RED" \
"2" "COLOUR IS $GREEN" 3>&1 1>&2 2>&3)

How can I colour $RED and $GREEN ?

2 Answers

Since version 0.52.13 (released in 2011), you can use the NEWT_COLORS environment variable, e. g.:

#!/bin/bash

export NEWT_COLORS='
window=,red
border=white,red
textbox=white,red
button=black,white
'

whiptail ...

Alternatively, you can create a config file with your palette and reference it using the NEWT_COLORS_FILE variable. See this answer for more information.

The patch was originally created by the Ubuntu community but later accepted in the upstream.

whiptail doesn't have relevant command-options or configuration files to change its color scheme. You can see what it does by reading its source-code:

dialog does have this capability (see screenshots).

Related