0

When using read command to get user input like the following

read -p "[WARN] Text.. [Y/N]" choice

Is it possible to assign an ANSI color to the warning text, like in echo command?

WARN='\033[0;33m'
RESET='\e[0m'

echo -e "${WARN}Some warning message${RESET}"
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
revy
  • 3,945
  • 7
  • 40
  • 85

1 Answers1

0

As Some programmer dude mentioned, you can simply

warn='\033[0;33m'
reset='\e[0m'

echo -e -n "${warn}[WARN] Text.. [Y/N] ${reset}"
read choice
l0b0
  • 55,365
  • 30
  • 138
  • 223