The pieces that get involved during shell startup, are /etc/profile which calls all the /etc/profile.d/*sh scripts, including /etc/profile.d/colorls.sh This uses a configuration file based on the TERM type. For xterm, it uses /etc/DIR_COLORS.xterm but for aixterm, it picks up the default /etc/DIR_COLORS It then calls dircolors --sh /etc/DIR_COLORS which sets up (or not) the LS_COLORS environment variable. If LS_COLORS is empty like it is for aixterm's, then ls will never do colors, even if you try to force it to by ls -l --color=yes 031225.tar.Z - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - You can get colorized ls to work for aixterm windows by creating a /etc/DIR_COLORS.aixterm file. I modified the xterm one. The problem now though, is that aixterm doesn't reset the colors back to what they should be at the end of a command, be it ls or vim or more. To demonstrate, a ls -l --color=yes 031225.tar.Z command, types that 031225.tar.Z name in red, then puts out the $PS1 prompt and cursor both in red, and whatever you type in, also is red. You can reset this with an echo "\033[97;101m" command. This leads one to come up with a neat solution which works to a point, by bracketing my normal PS1 setting with these aixterm control codes to reset the color each time before printing out the $PS1 prompt. It turns out, you also need to "erase to the end of the line" else the cursor stays red. That's accomplished with the [0K. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - So to fix Linux's irritating tendency to leave screen colors screwed up, (e.g. the colorized ls command or the vim editor or more), try putting the following code in your .profile or .bashrc or .kshrc as appropriate. Beware of special characters in these lines. The bash shell allows us to use \e for the Escape key (decimal 27 = hex 1b = octal 33). But what looks like ^[ on the ksh lines, are really one character, the Escape key. You'll get the wrong thing if you "swipe" them. The way to enter them under vi, is ctrl-v Esc. The Escape-[...m sequence is to send "set graphic rendition" commands to the aixterm program (see the aixterm help text for details). We are sending two commands, 97 to set the foreground color and 101 to set the background color. The trailing 0K sequence erases to the EOL. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if [[ $TERM = aixterm ]] then if [[ $0 = *bash ]] then export PS1="\e[97;101m<$(whoami)@$(hostname -s):"'$PWD> \e[0K' else export PS1="<$(whoami)@$(hostname -s):"'$PWD> ' fi else # It's probably Linux's xterm window then. if [[ $0 = *bash ]] then export PS1="\e[0m<$(whoami)@$(hostname -s):"'$PWD> \e[0K' else export PS1="<$(whoami)@$(hostname -s):"'$PWD> ' fi fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The above works just fine for my default aixterm color scheme of aixterm -bg maroon -fg white But start the aixterm with -bg white -fg black (apparently, Linux's xterm default), and things don't work. First of all, before you even do anything, after ssh-ing in, the screen immediately gets an orange background. The problem is that the "\033[97;101m" sequence doesn't work the same. For this type of window, you need "\033[30;47m", or export PS1="<$(whoami)@$(hostname -s):"'$PWD> ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Trying to get one PS1 setting to work in both cases, causes great confusion. I can't get a good PS1 setting to work in all situations. Google-ing +linux +aixterm +color gets me http://swexpert.com/C6/RS.C1.MAY.98.pdf, which explains a bit about standardized codes (ISO 6429). He says that \033[1;33;0;44m for example, should give a bright (the 1) yellow text (the 33) on a blue background (the 44). The ISO 6429 standard codes are Foreground Background Other Colors Colors Codes ========== ========== ================= 30=Black 40=Black 0=Restore Default 31=Red 41=Red 1=Brighter Color 32=Green 42=Green 4=Underline 33=Yellow 43=Yellow 5=Blink 34=Blue 44=Blue 35=Purple 45=Purple(aka magenta) 36=Cyan 46=Cyan 37=White 47=White It also mentions the LS_COLORS environment variable (set in Linux by the dircolors command in /etc/profile.d/colorls.sh) and its 2-character abbreviations for different file types you can color differently, bd=Block Device mi=Missing File cd=Character Device no=Normal Text di=Directory or=Orphaned Link ex=Executable pi=Named Pipe fi=Regular File so=Socket ln=Symbolic link Lastly, it says all you need in your PS1 prompt to reset aixterm's colors, is export PS1="\033[0m ...and the rest of your prompt" but this doesn't work for either of my aixterm cases. ?????? Maybe in .profile/.kshrc, if TERM=aixterm, then export TERM=xterm?? ?????? ???? Unset COLORTERM ??? ???? Remember setting TERM=hft or lft instead of aixterm? ???? Use the reset command (which is really tset init)? ?? infocmp command to see termcap entries ?? tput init or tput bce ?? tic=translates the terminfo description files from source to compiled format In another web page titled "Andys Terminfo Package" (that I had to see from Google's cached copy 'cause the original at http://www.nyangau.fsnet.co.uk/terminfo/terminfo.htm wasn't there), said The AIX aixterm terminfo definition, as shipped with AIX 4.3 and AIX 5.0 is broken. It omits the bce entry, and incorrectly encodes the op original pair as green on black rather than the white on black it should be. The old AIX Extended Curses implementation doesn't seem to mind these errors, but the newer AIX Curses implementation ends up drawing swathes of background in the wrong colour, and anything which should be white on black comes out green on black. Accordingly, this TERMINFO package will need to override the standard aixterm entry, but doesn't yet. I found http://www.unet.univie.ac.at/aix/files/aixfiles/terminfo.htm and it said bce is the "Cap Name" that "Erases screen with current background." The bottom line is, I could get a PS1 prompt to work for a specific instance, but I couldn't come up with a PS1 that would work in all cases.