xterm & aixterm Notes

See the xterm escape sequences for details, but in summary, to set both the icon & window titles,
 or  \033]0;string\007
Note that most terminal emulators (eg, PuTTY), emulate xterm.

Couple that with what bash can do for you, and you have two possibilities;

  1. bash supplies a variable $PROMPT_COMMAND which contains a command to execute before the prompt, so you can (re)set the window title after each command with
       PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
    This is what Linux does for (to?) you in its /etc/bashrc file, set PROMPT_COMMAND to
       PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
  2. A better way is to take advantage of the following shortcuts bash provides you when it's evaluating the PS1 string. Note these shortcuts only work when evaluating $PS1. They won't work in a normal echo command or in the $PROMPT_COMMAND string. And they only work under the bash shell. Solaris in particular, default to the Bourne shell, sh.
       \u          expands to $USERNAME
       \h          expands to hostname up to first '.'
       \w          expands to directory, replacing $HOME with '~'
       \$          expands to '$' for normal users, '#' for root
       \[...\]     embeds a sequence of non-printing characters
    IMO, the best way to set both the window title & command line prompt is
       unset PROMPT_COMMAND
       export PS1="\[\033]0;\u@\h: \w\007\]\w \\\$ "
Playing around with $PROMPT_COMMAND and $PS1 can get very confusing when you set PROMPT_COMMAND to change the window title, but it doesn't change. Remember that PROMPT_COMMAND runs before PS1, so if both are trying to set the window title, PS1 takes precedence.

  To temporarily reset the colors of your aixterm back to "normal",
         under ksh, try echo    "\033[0;10;97;101m\033(B\033[H\033[J"
under Linux's bash, use echo -e "\033[0;10;97;101m\033(B\033[H\033[J"

Note this works for ME, with my default colors.  This is not a general reset
mechanism.  IE if your aixterm uses different colors than mine does, this command
may not reset your screen to your original colors.  Play with the 97 & 101,
using other numbers in the 90-97 & 100-107 range.

  Refer to the aixterm command reference for details, but here is how to do
some slick things with aixterm output.

For all, mytext='This is special'

To change the aixterm window title, print "\033]2;$mytext\a\c"
          To change the icon title, print "\033]1;$mytext\a\c"
                    To change both, print "\033]0;$mytext\a\c"

Under Solaris's bash using PuTTY, use echo -ne "\033]L$mytext\007"
or put it in your PS1, ala export PS1="\033]L\u@\h:\w\007\u@\h:\w$ "

Some notes on the above,
    - The aixterm documentation says this should be ESC]Ps;Pt\007
    - ESC means the ESCape key, which is the \033 above,
    - ] is a literal,
    - the Ps means the subcommand(?), and is 0, 1, or 2.
    - the semicolon (;) is another literal,
    - the Pt means whatever text you want(?).
    - \007 is the bell, which is specified by the \a in the print command,
    - The \c in print, says to not put out a newline character for this output.

Given all that, how do you interpret ESC[Ps m     (see next section below)
                                  or ESC[?Ps;...;Ps h in the aixterm documentation?
    - ESC means the ESCape key, which is the \033 above,
    - [ is a literal,
    - the Ps is the subcommand(?) and Ps;...;Ps means you can put as many subcommands
      as you wish,
      Some of the interesting subcommands are
          For Ps m,
            0 = normal
            1 = bold
            4 = underscore
            5 = blink (appears as bold)
            7 = reverse
            8 = invisible
          For ?Ps h,
            1 = normal/application cursor
            3 = 80/132 columns
            5 = reverse/normal video
           42 = hide/show scrollbar
    - and the "m" or "h" are more literals.

If so, some of these work, but others don't work:
  - This prints out reverse text, which is like it being highlighted.  Pretty useful.
      print "Normal text \033[7m$mytext\033[0m Again, normal text"
    Be warned that if you pipe this into more, you'll lose your highlighting.  Poop!
    But this can still be useful in a limited way.  For example, say you want
    to look for "TBC" in a file, but there's a lot of output, long lines, etc.
      egrep -ni 'tbc' /ips/convdata/usa02week17/pg020423.xml 2>/dev/null
    on patimg1 produces 83 lines & 42K of output.  But
      print "$(egrep -ni 'tbc' /ips/convdata/usa02week17/pg020423.xml 2>/dev/null | \
         sed 's/[tT][bB][cC]/\\033[7m&\\033[0m/g')"
    will nicely highlight all the TBC's for you, even if mixed case.
    You can then use your aixterm scroll bar to scroll through it all.
    You've got to visually go through it, but the TBC's get lost.  H

  - You'd think this would be bold-ed (whatever that means), but it doesn't
    seem to change anything.  (Maybe 'cause I normally run in bold mode??)
      print "Normal text \033[1m$mytext\033[0m Again, normal text"

  - Underlining works, though.
      print "Normal text \033[4m$mytext\033[0m Again, normal text"

  - Blinking doesn't work.
      print "Normal text \033[5m$mytext\033[0m Again, normal text"

  - Reversing works, but what use is that?
      print "Normal text \033[8m$mytext\033[0m Again, normal text"

  - This print "\033[?1h\c" for "normal/application cursor" didn't seem to change the cursor.

  - This print "\033[?3h\c" for "80/132 columns" didn't seem to change anything either.

  - This print "\033[?5h\c" did indeed reverse the video, making the background white
    instead of maroon, and the text maroon instead of white, but doing it again, doesn't
    put it back the way it was.  And I don't know how to put it back the way it was.

  - This print "\033[?42h\c" for "hide/show scrollbar" didn't work either.


  When things get screwed up at an aixterm window, for example, after running nmon,
you can use some of the "set graphic rendition" (sgr) subcommands of aixterm to restore

  For example, to restore sanity at my aixterm windows, try
    echo "\033[0;10;97;101m"

This sends multiple "commands" to the aixterm.  As best as I can determine,
    0 means "normal".  I.E. it resets certain things.  For example, it restores the echo
      and turns off underlining.
   97 sets the character color the the white that I like.
  101 sets the background to the maroon that I like.
(For Linux's xterm, you need echo "\033[0;10;99,108m")

Other possible necessities are
    echo "\033(B" to select US ASCII character set
    echo "\033[H" to move cursor to the top of the screen
    echo "\033[J" to clear display

If you want to play with this, this will screw up your terminal settings,
    echo "\033[8;40;100m"
    8 will turn off echoing at your console.
   40 sets the character color to reverse white?
  100 sets the background to gray.

  You can use this little command at the ksh command prompt,
while read i;do echo "\033[${i}m";echo "That was echoing out escape-left square bracket-${i}m";done


  Other of these "m" commands include
     null = reset?  At least, it turns off underlining.
        0 = same as null?
        4 = Turn on Underlining (null or 0 resets)
        7 = Turn on Reverse Video (null or 0 resets)
        8 = Hides all text (null or 0 resets)
    10-17 = ???  All the documentation says is "fonts".
    30-37 = Turns foreground (i.e. the characters) different colors, apparently all bold.
            Matches the 90-97 colors.  For example,
                34 = Turns characters dark blue,
                94 = Turns characters light blue.
            Also matches the 40-47 range for the background.  For example, to match the
            characters with the background, making the characters invisible,
                echo "\033[37m;\033[47m"
            making both white.

    40-47 = Turns background different colors

       48 = Does strange things to the characters, putting small vertical lines
            between each character (null or 0 resets)
       49 = Underlines with a different color than 4 did

    90-97 = Turns the foreground (i.e. the characters) different colors, apparently not bold.
            See 30-37 above.
       97 = Turns the characters the white that I like, i.e. echo "\033[97m"

  101-107 = Turns background different colors
      101 = Turns background to the maroon color I like, i.e. echo "\033[101m"


See /usr/lpp/X11/lib/X11/fonts for the fonts you can use with aixterm.

These will all be compressed pcf files, i.e. Rom10.iso1.pcf.Z, which you use with
aixterm via
  aixterm -fn Rom10.iso1
for example.

  When some command is interrupted or when binary output is sent to an
aixterm window, the terminal settings get set to funny things.
To restore, try
   stty -echo
or stty sane    To return things to a "sane" condition.

To see some settings,
or stty -a       To see all settings.