?
Solved

reverse-video prompts in xterm on SunOS

Posted on 1997-06-13
6
Medium Priority
?
874 Views
Last Modified: 2013-12-27
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.
0
Comment
Question by:JohnChambers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Expert Comment

by:mlev
ID: 2006413
I have one that works on SunOS 5.5, but it's only for tcsh.
set prompt="%S%n@%m:%~%s%#"
0
 
LVL 1

Expert Comment

by:henrys
ID: 2006414
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

0
 

Author Comment

by:JohnChambers
ID: 2006415
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.
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Author Comment

by:JohnChambers
ID: 2006416
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.
0
 
LVL 3

Accepted Solution

by:
braveheart earned 100 total points
ID: 2006417
Both examples worked fine for me and I am using an xterm on Solaris right now so it is probably something wrong in your terminal setup.

Although your prompt setup should normally be established in the
.cshrc (so that you can look to see if it is set to distinguish between terminal sessions and script driven shells) it is more usual for the terminal setup to be in the .login file (so you only perform it once and not for every shell). However, don't forget that in your login shell, .cshrc is sourced before .login. This means that if you are using the tput method then it may not know what terminal type you are using until after you have set the prompt.

In .login add the following lines:

set noglob
eval `tset -s xterm`
unset noglob

Check that TERM is set to xterm when you have logged in.

For more info, check the man pages on tset and stty.


0
 
LVL 3

Expert Comment

by:braveheart
ID: 2006418
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.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question