I'm writing my own Unix ls command in c and I was wondering if anyone knows how to or can point me to a tutorial that shows me how to change the text color of the filename depending on if it's a directory, regular file, linked file, etc..., like the real ls command does? Thanks.
Yeah, basically you print the escape character (either \e or \033, I prefer the latter because I'm used to it and \e isn't actually standard C - although as far as I know it is widely supported), an opening square bracket ('['), numbers separated by semicolons and the letter 'm' (other letters are used for other types of escape codes).
To get back to the default, you must use '0' as the number. If several numbers are specified they will be executed in the order they appear, thus if two incompatible options are set (like green and red at the same time), the last one will be effective. You can prefix all your options with a '0' like "\033[0;<your options here>m", in case some of them are already set.
Don't forget to print a "\033[0m" at the end if you don't want the rest of your output to be messed.
For a reference on ANSI escape codes, see here
Hello!
I need to write a bash script for my university classes, and I came up with an idea of a program that would test the speed of typing - there is some random text that you have to rewrite, and the script measures time, number of mistakes etc. The text would be visible on the screen all... (3 Replies)
Hi,
I am trying to write a python program which changes background color on click of button. However i am stuck up. Instead of changing the color currently it is creating a new frame every time.
please look at the code and let me know how to correct it
#!/usr/bin/env python
from Tkinter... (0 Replies)
Hi all
I have a file contains columns showing figures as below :
Input file
A B C
D 50 60 90
E 100 20 53
F 30 40 70
G 25 27 45
I want to color the value above or equal 90 by red and to be shown as below
output file... (5 Replies)
On solaris and irix systems, I'm using csh in an existing xterm or dterm and would like to change the text colors. How do I accomplish this?
Thanks (1 Reply)
Hi all,
Can you tell me how to change the prompt color (only the path part) when I chnange directory with "cd"?
I use the sequence below in ".bashrc" (Solaris 8) to change my prompt colors and I'd like to modify it to change the path color when I cange directory.
PSC() { echo -ne "\"; }... (0 Replies)
Hi,
I want to change the color of the text. Currently, I am using the following VT100 command, which changes the color of the foreground:
<ESC>[{attr1};...;{attrn}m
The problem is, when I change the color of the foreground, it changes the color of the text as expected, but it also... (4 Replies)
Hi,
We have process log with user defined error messages and information echos. I wanted to highlight error messgaes in that log file while writing in it. Is there any option with either echo or any other command which enables making text bold or we can change the font of body text of echo.
... (4 Replies)