Colors in Terminal

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
cmpitg
Posts: 10
Joined: Thu May 05, 2011 1:10 am
Location: Hanoi
Contact:

Colors in Terminal

Post by cmpitg »

Hi guys,

I'm developing a console application which makes use of VT-100 compatible terminals. Usually, to produce text color, I use the escaped phrase `\\033$COLOR_CODE`. For example, to output the world "Hello world" in red, I use

Code: Select all

echo "\\033[41mHello world!"
In newLISP, I tried to do the same thing with

Code: Select all

(println "\\\\033[41mHello world!")
(println {\\033[41mHello world!})
But neither works. Does anyone know how to produce colors in terminal with newLISP?
"Life is a hack"
My web log: http://cmpitg.wordpress.com

m i c h a e l
Posts: 394
Joined: Wed Apr 26, 2006 3:37 am
Location: Oregon, USA
Contact:

Re: Colors in Terminal

Post by m i c h a e l »

This works using Terminal on OS X:

Code: Select all

(println "\027[0;31mHello world!\027[0m")
Hope this helps.

m i c h a e l

cmpitg
Posts: 10
Joined: Thu May 05, 2011 1:10 am
Location: Hanoi
Contact:

Re: Colors in Terminal

Post by cmpitg »

Thank you very much! I'm using ROXTerm in Gentoo GNU/Linux with Zsh and it works beautifully :-).

Now I understand. ASCII's 033 in octal is equivalent to 27 in decimal. (Somehow) newLISP uses decimal system to describe escape codes instead of octal.
"Life is a hack"
My web log: http://cmpitg.wordpress.com

Camryn65
Posts: 3
Joined: Thu Jan 05, 2012 9:27 am

Re: Colors in Terminal

Post by Camryn65 »

Is there any way to apply colors in terminal in order files/folders to differ when i connect to a server ? As you know files/folders are the same color so it would be easer for me to recognize folders or files at a glance. I have made this change
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
export PS1="\[\033[1;32m\][\$(date +%H:%M)][\hu: \W$ \[\033[0m\] "
but it doesn't work with ssd connection through terminal.
thanks!!

Locked