This webpage explains nicely how to get colour into any output of the
> echo \\e[1\;30mBLACK\\e[0m BLACK > echo '\e[1;30mBLACK\e[0m' BLACK
The word 'BLACK' in the example above is printed with a black (or darkgrey) foreground colour (depending on the overall color scheme).
Now I'd like to introduce this into the
[TAB] command autocompletion feature of
tcsh. I tried:
complete testcmd 'p/*/`echo '"'"'\e[1;30mf834fef\e[0m'"'"'`/'
And I get:
> testcmd [TAB] > testcmd ^[\[1\;30mf834fef^[\[0m
Obviously the characters lose their special meaning. Hopefully I just did not get the escaping right. But I tried several other ways. So any help is appreciated.
The real use case is that I've got a command completion that offers three different types of completions and I'd like to visually distinguish the types. Also the alternatives are computed by an external command. That is why I need the completion to use the backticks with an external command, such as
echo. I don't care about the details of this command. If you make it work in any way with the
complete command I'll probably be able to adapt (thinking
perl -pe wrappers and such).
The reason why I believe this has to work somehow is that the tcsh itself offers coloured command completion if you e.g. type
ls [TAB]. That works correctly in my setup. Also you can use
ls -1F inside the autocompletion and the colours that
ls outputs are also piped through. An example would be:
complete testcmd 'p/*/`ls -1F`/'
Update: As user mavin points out on stackoverflow, the colourization of
ls in this example is indeed not piped through. The colours of
ls are lost, but the auto completion can reapply colours according to LS_COLOURS variable based on hints such as the
* marker endings as added by the ls. This can be verified by doing
complete testcmd 'p/*/`ls --color -1`/'
which fails to provide colour, and only provides garbled output. (Literally pipes through the escape character sequences)
tcsh version 6.13.00
Any ideas? Pointers?