I am using bash 4.4. I have colors enabled, and I see colors when hitting for example double tab after a ls command (files and folders in different colors). I have inside my ~/.inputrc the set colored-stats on setup.
However I am still not able to use colors with the complete command. For example, I have the following test file:
colored_output="\033[0;31mPaul\033[0m"
echo -e $colored_output # this prints 'Paul' in red
_hello () {
COMPREPLY=()
COMPREPLY+=("Bob")
COMPREPLY+=("Alice")
COMPREPLY+=("${colored_output}")
}
complete -o nosort -o filenames -F _hello hello
when sourcing it, Paul is printed in red as it should. But things do not work when hitting double tab on hello (all of this displays in the default terminal color):
$ hello [hitting TAB TAB now]
Bob Alice \033[0;31mPaul\033[0m
Any idea how to get color after the TAB autocompletion too? I think I somehow need to say to complete that \ should be used as an escape char?