I frequently pipe the output of Terminal.app commands to view/search with TextMate, but for commands like "ls -al --color=always" I'd like to still see the ANSI terminal colors even though I keep the piped output in Textmate for future reference.
So something like % echo -e "\e[0;32mCOLOR_GREEN\t\e[1;32mCOLOR_LIGHT_GREEN\e[0m" would show up (colored) in TextMate as COLOR_GREEN COLOR_LIGHT_GREEN It'd be fine if the actual escape codes were still there but de-emphasized.
If nothing else, it would save me from running a regex through search/replace to remove the ANSI escape codes when my output already took a while to generate. And I like the "do it once, keep it forever" factor of a TextMate bundle ;)
If there's any existing bundle which has those codes already in a language grammar, I'd appreciate it.
Thanks Darryl
ls example: total 8.0K -rwx--x--x 1 dzurnlocal 515 2010-04-14 16:16 [0m[01;32mcolors.sh[0m* lrwxr-xr-x 1 root 9 2007-07-05 10:06 [01;36m2-sym_link[0m -> [01;33m/dev/null[0m brw-r--r-- 1 root 14, 0 2006-06-09 15:38 [01;33m6-block_special[0m crw-r--r-- 1 root 3, 2 2006-06-09 15:38 [01;33m7-char_special[0m -rw-r--r-- 1 dzurnlocal 0 2006-06-09 15:38 0-file drwxr-xr-x 2 dzurnlocal 68 2006-06-09 15:38 [01;34m1-directory[0m/ -rwxrwxrwx 1 dzurnlocal 0 2006-06-09 15:38 [01;32m5-executable[0m* -rwsrwxrwx 1 dzurnlocal 0 2006-06-09 15:38 [37;41m8-exe_setuid[0m* -rwxrwsrwx 1 dzurnlocal 0 2006-06-09 15:38 [30;43m9-exe_setgid[0m* drwxrwxrwt 2 dzurnlocal 68 2006-06-09 15:38 [30;42ma-dir_writeothers_sticky[0m/ drwxrwxrwx 2 dzurnlocal 68 2006-06-09 15:38 [34;42mb-dir_writeothers_NOsticky[0m/
Unfortunately there is no easy way to emulate that in TextMate since ANSi codes are stream based and TextMate is scope based. I'm tempted by the challenge, but I just don't think it's worth the amount of time it would take to make it mostly work.
Sorry
dzurn wrote:
I'd like to still see the ANSI terminal colors even though I keep the piped output in Textmate for future reference.
So something like % echo -e "\e[0;32mCOLOR_GREEN\t\e[1;32mCOLOR_LIGHT_GREEN\e[0m" would show up (colored) in TextMate as COLOR_GREEN COLOR_LIGHT_GREEN
On 2010-04-16 07:59, subtleGradient wrote:
Unfortunately there is no easy way to emulate that in TextMate since ANSi codes are stream based and TextMate is scope based. I'm tempted by the challenge, but I just don't think it's worth the amount of time it would take to make it mostly work.
I was thinking maybe something could be done by treating the escape codes much the same way as you would opening/closing tags in HTML. Unfortunately that wouldn't remove the codes from the display. IMHO that limitation would destroy the usefulness.
On the other hand, it should be fairly simple to reformat the ANSI codes as HTML. Just write a command to convert the document and display it as HTML. That would at least make it pleasing to the eye, without modifying the ANSI sequences in the original file. You couldn't edit in the HTML window, but I get the impression that dzurn isn't looking for something editable. Try the Perl script ansi2html as a starting point.
http://search.cpan.org/~autrijus/HTML-FromANSI-1.01/script/ansi2html http://search.cpan.org/%7Eautrijus/HTML-FromANSI-1.01/script/ansi2html