Visit Our UNIX and Linux User Community

Changing korn shell script text Menu colors?

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Changing korn shell script text Menu colors?
# 1  
Old 12-13-2001
Changing korn shell script text Menu colors?

Is it possible to change the color of text in a korn shell script Menu?

I can change the color of session text through my telnet client but I want to be able to change color text in the Korn shell menu to highlight certain items.
# 2  
Old 12-13-2001
Assuming your terminal supports ANSI colors, it is quite easy. You just need to add certain echo statements to achieve certain colors.

The syntax is: echo "^[[#m<text>"

Where the the "^[" character is produced by hitting ctrl-v and then escape and # is substituted with a number depending on the effect you want the second "[" and the "m" are literal characters. Here's an excerpt from some C code listing the various colors (because I'm too lazy to retype it in a different format):

/* foreground colors */
#define AFC_BLACK           30
#define AFC_RED             31
#define AFC_GREEN           32
#define AFC_YELLOW          33
#define AFC_BLUE            34
#define AFC_MAGENTA         35
#define AFC_CYAN            36
#define AFC_WHITE           37

/* ansi background colors */
#define ABC_BLACK           40
#define ABC_RED             41
#define ABC_GREEN           42
#define ABC_YELLOW          43
#define ABC_BLUE            44
#define ABC_MAGENTA         45
#define ABC_CYAN            46
#define ABC_WHITE           47

/* ansi modes */
#define AM_NORMAL               0         
#define AM_BOLD                 1
#define AM_LOWINTESITY          2
#define AM_ITALIC               3
#define AM_UNDERLINE            4
#define AM_BLINK                5
#define AM_RAPIDBLINK           6
#define AM_REVERSE              7
#define AM_INVISIBLE            8

You can combine the modes, so to print the word "hello" in yellow text on a blue background and then return to normal you would use:

echo "^[[33m^[[44mhello^[[0m"
# 3  
Old 12-13-2001
What about chaning output text?

Thanks for the reply. That works great with echo, but is there also a way to change the output text of a command to a alternate color also?
# 4  
Old 12-21-2001
Changing color with other commands?

Is it possible to change the color output on other commands like.

banner "^[[31m^[[44m Hello ^[[0m"
# 5  
Old 12-24-2001
Data hi

the text colors with banner comand is not coming....
what about the anci mode in the last field how to get blinking text with colours.....

please suggest
# 6  
Old 12-28-2001

Good question. Suggestion on blinking text colours anyone?
# 7  
Old 01-20-2002
what else does this work for?

I figure that this must be the ANSI standard for colours for ANSI terminals, so it will work for perl scripts, bash scripts and so on?

It seems to on my terminal, however I am a little skeptic with these things in a live environment.


Previous Thread | Next Thread
Test Your Knowledge in Computers #27
Difficulty: Medium
Linux was the first fully supported 64-bit operating system for consumers.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to call a menu script and redirect each option to a text file

Hello, I want to design a script that will call an existing menu script and select options one by one and redirict the out put to a file. For example;- In the script there are 10 options i want to design a script that will select option 2 3 4 6 7 10 and redirict the output... (4 Replies)
Discussion started by: spradha
4 Replies

2. Shell Programming and Scripting

Change text color in Korn shell to highlight Error

Hi this is my first post, so forgive me if what I'm requesting doesn't make sense. I'm connecting into a Unix server via SSH and using a Korn Shell (#!/bin/ksh). The Unix server has Oracle 11g installed on it and there are a number of scripts already setup to query the Oracle database to perform... (2 Replies)
Discussion started by: KeithJ
2 Replies

3. UNIX for Dummies Questions & Answers

Changing colors for compiler errors/warnings

Hi, I am using GNU unix. And running a bash shell. Can anyone please tell me what is the command for changing the color of the compiler error/warning messages on the console. I think it is in .bashrc and do not know how. Thanks Pink (1 Reply)
Discussion started by: pink01
1 Replies

4. UNIX for Advanced & Expert Users

Changing colors for compiler errors/warnings

Hi, I am using GNU unix. And running a bash shell. Can anyone please tell me what is the command for changing the color of the compiler error/warning messages on the console. I think it is in .bashrc and do not know how. Thanks Pink (0 Replies)
Discussion started by: pink01
0 Replies

5. Shell Programming and Scripting

shell script for changing two text files

HELLO I am new in shell bash script> I have two text files.They contain same datas. I want to change some text in two files.If I changed in one file.Then I want to change another same file without using vieditor.Iwant to change another file by using shell script for example file1 hello good... (7 Replies)
Discussion started by: vidhun.v
7 Replies

6. OS X (Apple)

Changing OSX Terminal Man Page Colors

For a long time, when I type man anything on my Mac, both the manpage header fonts and the background was black, so I had to use my mouse to highlight the manpage output to read it. It was really annoying. The problem was the same both locally or using the terminal and going ssh somewhere. ... (1 Reply)
Discussion started by: Neo
1 Replies

7. Solaris

Changing CDE FrontPanel Button Colors

OK so I've been trying to figure this out on and off for about two years on Solaris 8, and now I'm trying to do it in Solaris 10 (which seem to have identical resource structures for Dtwm.) I've created my own sleek, single row front panel with small custom icons, and smaller font so that it's... (1 Reply)
Discussion started by: insamniac
1 Replies

8. Shell Programming and Scripting

How to: Parse text string into variables using Korn shell

I am writing a script to keep check on free disk space, and I would like to find a way to parse $LINE (see code below) into a numeric value (for free disk space percentage) and a string value (for mount point). If possible, I would like to avoid sed or any additional use of awk since I am not very... (7 Replies)
Discussion started by: shew01
7 Replies

9. UNIX for Dummies Questions & Answers

changing the colors of nedit

I have only slight difference between remarks (gray) and code (black) using c and c++ how cani change remark to other color ? The option preferences/language mode/c++ doesn't help (0 Replies)
Discussion started by: eynkesef
0 Replies

10. Shell Programming and Scripting

Changing a CSV file in Korn shell

Hi All, Please can someone help me how I can read a CSV file with 10 columns and remove the 2nd, 4th, 6th, 8th column and build the new output file. Script to be done in Korn shell. File contains data like bnt, lb2, lb3, vnw, lb4, lb5, bst, lb6, lb7, vgw (multiple rows) Output file should... (2 Replies)
Discussion started by: riteshm
2 Replies

Featured Tech Videos