Link to home
Start Free TrialLog in
Avatar of JohnChambers
JohnChambers

asked on

reverse-video prompts in xterm on SunOS

How does one get a reverse-video prompt in [t]csh on an xterm on a SunOS 4.1.4 system?  The code I have that works on most other system fails here.  Instead of getting reverse video, I get the ^[[7m style interpretation, which isn't pretty.  Something on the Sun is intercepting the ESC characters and replacing them with ^[ so the xterm doesn't see the escape sequence.

Does someone have a .cshrc code fragment that successfully produces a reverse-video prompt on a SunOS xterm?

Here are the definitions that work elsewhere but not here:

#   setprompt   'set prompt="^[[7m$USER@$HOSTNAME":"$wd3":"^[[m "'
#   setprompt   'set prompt="`tput smso`$USER@$HOSTNAME":"$wd3":"`tput rmso` "'


You should replace the ^[ pairs with an ESC char, of course.
Avatar of mlev
mlev

I have one that works on SunOS 5.5, but it's only for tcsh.
set prompt="%S%n@%m:%~%s%#"
This works for me (SunOS 4.1.3):
pau# echo $shell
/bin/csh
pau# echo $TERM
xterm
pau# alias setprompt
set prompt="^[[7m$USER@$HOSTNAME":"$wd3":"^[[m "
pau# setprompt
root@pau:/:  <-- this comes out in reverse video

The "Enable Reverse Video" item under the "VT Options" menu is _NOT_ checked.

Try seeing what the shell thinks your $TERM is

Avatar of JohnChambers

ASKER

Didn't work at all for me.  Here's the result of one of several
tests:

honk-jmc-3% set prompt="^[[7m$USER@$HOSTNAME"^[[m"
Unmatched ".
honk-jmc-4% set prompt="^[[7m$USER@$HOSTNAME":"^[[m"
^[[7mjmc@honk:^[[m

The prompt came out with the "^[[7m" string; this should have been interpreted as "switch to reverse video" but it wasn't.

Part of the evidence of what may be wrong is that when I type
a command, and include an ESC char, the screen flashes.  This
presumably means that some routine (maybe in the device driver,
maybe in the shell) is noticing the ESC and acting on it rather
than passing it in as a data char.  Thus, when I include an
escape sequence in the prompt string, the ESC doesn't make it
into the string, or maybe is there but in garbled "^[" form.
The %S...%s worked.  And, after I knew what it was, I even found
it in the tcsh man page.  Of course, they called it by a name
that I'd never heard before ("standout mode"), so even if I'd
thought to grep through `man tcsh`, I still probably wouldn't
have ever found it.  Anyway, I now have yet another strange way
to do this useful thing.  Thanks.
ASKER CERTIFIED SOLUTION
Avatar of braveheart
braveheart

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For a terminal independent way of inserting control sequences
into prompts, etc., use the tput command. So to switch to reverse
video execute "tput smso" or "tput rev" and to switch back use
"tput rmso" or "tput sgr0".

tput can also be used for ringing the bell, moving the cursor
and so on, all in a reasonably portable manner.