Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Changing korn shell script text Menu colors? Post 11891 by PxT on Thursday 13th of December 2001 01:28:13 PM
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):

Code:
/* 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"
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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 MENU.sh there are 10 options i want to design a script MENU2.sh that will select option 2 3 4 6 7 10 and redirict the output... (4 Replies)
Discussion started by: spradha
4 Replies
Deprecated names(3)						      BrlAPI						       Deprecated names(3)

NAME
Deprecated names - Data Structures struct brlapi_writeStruct Macros #define brlapi_settings_t brlapi_connectionSettings_t #define BRLAPI_WRITESTRUCT_INITIALIZER BRLAPI_WRITEARGUMENTS_INITIALIZER #define brl_keycode_t brlapi_keyCode_t #define brl_type_t brlapi_packetType_t #define BRLCOMMANDS NULL #define BRL_KEYCODE_MAX BRLAPI_KEY_MAX #define brlapi_initializeConnection brlapi_openConnection #define brlapi_getTty brlapi_enterTtyMode #define brlapi_getTtyPath brlapi_enterTtyModeWithPath #define brlapi_leaveTty brlapi_leaveTtyMode #define brlapi_unignoreKeyRange brlapi_acceptKeyRange #define brlapi_unignoreKeySet brlapi_acceptKeySet #define brlapi_getRaw brlapi_enterRawMode #define brlapi_leaveRaw brlapi_leaveRawMode #define brlapi_suspend brlapi_suspendDriver #define brlapi_resume brlapi_resumeDriver #define BRLERR_SUCCESS BRLAPI_ERROR_SUCCESS #define BRLERR_NOMEM BRLAPI_ERROR_NOMEM #define BRLERR_TTYBUSY BRLAPI_ERROR_TTYBUSY #define BRLERR_DEVICEBUSY BRLAPI_ERROR_DEVICEBUSY #define BRLERR_UNKNOWN_INSTRUCTION BRLAPI_ERROR_UNKNOWN_INSTRUCTION #define BRLERR_ILLEGAL_INSTRUCTION BRLAPI_ERROR_ILLEGAL_INSTRUCTION #define BRLERR_INVALID_PARAMETER BRLAPI_ERROR_INVALID_PARAMETER #define BRLERR_INVALID_PACKET BRLAPI_ERROR_INVALID_PACKET #define BRLERR_CONNREFUSED BRLAPI_ERROR_CONNREFUSED #define BRLERR_OPNOTSUPP BRLAPI_ERROR_OPNOTSUPP #define BRLERR_GAIERR BRLAPI_ERROR_GAIERR #define BRLERR_LIBCERR BRLAPI_ERROR_LIBCERR #define BRLERR_UNKNOWNTTY BRLAPI_ERROR_UNKNOWNTTY #define BRLERR_PROTOCOL_VERSION BRLAPI_ERROR_PROTOCOL_VERSION #define BRLERR_EOF BRLAPI_ERROR_EOF #define BRLERR_EMPTYKEY BRLAPI_ERROR_EMPTYKEY #define BRLERR_DRIVERERROR BRLAPI_ERROR_DRIVERERROR Detailed Description With version 0.5.0, BrlAPI is now provided through including <brlapi.h> and got a big renaming pass. Old names are still available through macros, but they are deprecated since they will get dropped in the next release. This documentation is for you to know the new names. For checking that you have completely switched to new names, just define BRLAPI_NO_DEPRECATED: that will disable compatibility macros. Macro Definition Documentation #define BRL_KEYCODE_MAX BRLAPI_KEY_MAX #define brl_keycode_t brlapi_keyCode_t #define brl_type_t brlapi_packetType_t #define brlapi_getRaw brlapi_enterRawMode #define brlapi_getTty brlapi_enterTtyMode #define brlapi_getTtyPath brlapi_enterTtyModeWithPath #define brlapi_initializeConnection brlapi_openConnection #define brlapi_leaveRaw brlapi_leaveRawMode #define brlapi_leaveTty brlapi_leaveTtyMode #define brlapi_resume brlapi_resumeDriver #define brlapi_settings_t brlapi_connectionSettings_t #define brlapi_suspend brlapi_suspendDriver #define brlapi_unignoreKeyRange brlapi_acceptKeyRange #define brlapi_unignoreKeySet brlapi_acceptKeySet #define BRLAPI_WRITESTRUCT_INITIALIZER BRLAPI_WRITEARGUMENTS_INITIALIZER #define BRLCOMMANDS NULL #define BRLERR_CONNREFUSED BRLAPI_ERROR_CONNREFUSED #define BRLERR_DEVICEBUSY BRLAPI_ERROR_DEVICEBUSY #define BRLERR_DRIVERERROR BRLAPI_ERROR_DRIVERERROR #define BRLERR_EMPTYKEY BRLAPI_ERROR_EMPTYKEY #define BRLERR_EOF BRLAPI_ERROR_EOF #define BRLERR_GAIERR BRLAPI_ERROR_GAIERR #define BRLERR_ILLEGAL_INSTRUCTION BRLAPI_ERROR_ILLEGAL_INSTRUCTION #define BRLERR_INVALID_PACKET BRLAPI_ERROR_INVALID_PACKET #define BRLERR_INVALID_PARAMETER BRLAPI_ERROR_INVALID_PARAMETER #define BRLERR_LIBCERR BRLAPI_ERROR_LIBCERR #define BRLERR_NOMEM BRLAPI_ERROR_NOMEM #define BRLERR_OPNOTSUPP BRLAPI_ERROR_OPNOTSUPP #define BRLERR_PROTOCOL_VERSION BRLAPI_ERROR_PROTOCOL_VERSION #define BRLERR_SUCCESS BRLAPI_ERROR_SUCCESS #define BRLERR_TTYBUSY BRLAPI_ERROR_TTYBUSY #define BRLERR_UNKNOWN_INSTRUCTION BRLAPI_ERROR_UNKNOWN_INSTRUCTION #define BRLERR_UNKNOWNTTY BRLAPI_ERROR_UNKNOWNTTY Author Generated automatically by Doxygen for BrlAPI from the source code. Version 1.0 Fri Jun 7 2013 Deprecated names(3)
All times are GMT -4. The time now is 07:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy