5

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 ?

zlobul
  • 335
  • 1
  • 5
  • 20
  • Please provided a valid `whiptail` invocation. Your example has unbalanced quotes, and `$window` is unspecified. – Micah Elliott Oct 07 '17 at 16:09
  • Thanks, $window will get the current window size from the shell , but could be also manually adjusted . Fixed the quotes . – zlobul Oct 08 '17 at 06:07

2 Answers2

13

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.

Bass
  • 4,977
  • 2
  • 36
  • 82
  • Thanks a lot that works for almost everything , but am I able to highlight text ? – zlobul Nov 15 '17 at 09:48
  • @ElPopo Unfortunately, no. `dialog` has the `--colors` switch and can process embedded `\Z` sequences, but `whiptail` doesn't provide any similar functionality. – Bass Nov 15 '17 at 10:16
  • Thanks Bass , I will mark this as an answer as it is the closest solution I found so far ! – zlobul Nov 15 '17 at 16:16
2

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

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • Thanks , yes , right . I was hoping there is a "hack" to change the colour with whiptail... Unfortunately I can not use dialog for my project . – zlobul Oct 08 '17 at 14:42