Search code examples
javascriptshellcolorsterminalls

How to get color and formatting data from command in not interactive shell


I have terminal emulator in JavaScript that execute CGI scripts (via Ajax) and it would be nice to get colors and formatting information from the command, like ls --color=auto.

Is there a way to get data from non interactive shell (my CGI script) that display this information?


Solution

  • Not sure what you mean but

    ls --color=always
    

    will output in colour even if the output doesn't go to a terminal

    There's a aha tool to convert ANSI colour escape sequences to HTML (http://ziz.delphigl.com/tool_aha.php).

    ls --color=always | aha