Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

can one embed escape sequences in the prompt?

2 views
Skip to first unread message

Phillip Helbig---remove CLOTHES to reply

unread,
Dec 21, 2003, 7:19:02 AM12/21/03
to
I'm not saying it's necessarily a good idea, but can one embed escape
sequences in the prompt, e.g. to make it appear bold by using the
appropriate escape sequences for the terminal in question?

H Vlems

unread,
Dec 21, 2003, 8:41:50 AM12/21/03
to

"Phillip Helbig---remove CLOTHES to reply" <hel...@astro.multiCLOTHESvax.de>
schreef in bericht news:bs433m$2d8$5...@online.de...

> I'm not saying it's necessarily a good idea, but can one embed escape
> sequences in the prompt, e.g. to make it appear bold by using the
> appropriate escape sequences for the terminal in question?
>
Yes. But not necessarily usful :-)


VAXman-

unread,
Dec 21, 2003, 10:42:58 AM12/21/03
to

Yes.


--
http://www.legacy-2000.com for the *best* OpenVMS system security
solutions that others only claim to be.
--
VAXman- A Bored Certified VMS Kernel Mode Hacker VAXman(at)TMESIS(dot)COM

"Well my son, life is like a beanstalk, isn't it?"

Peter 'EPLAN' LANGSTOEGER

unread,
Dec 21, 2003, 1:11:23 PM12/21/03
to
In article <bs433m$2d8$5...@online.de>, hel...@astro.multiCLOTHESvax.de (Phillip Helbig---remove CLOTHES to reply) writes:

Yes, it is.

I use it for a decade now to restore video attributes or a bad scroll region
(like EDT which doesn't turn it off on exit but sets it to 24 lines which is
bad on DECterms with larger sizes).

$ sy_len = F$LENGTH (node) - 1
$ sy_str = F$EX (0, 1, node) + F$ED (F$EX (1, sy_len, node), "LOWERCASE")
$ us_len = 2
$ us_str = F$EX (0, 1, user) + F$ED (F$EX (1, us_len, user), "LOWERCASE")
$ pr_str = sy_str + "/" + us_str
$ prompt = esc + "(B" + esc + "[4l" + esc + "7" + esc + "[r" + esc + "8"
$ prompt = prompt + esc + "[1m" + pr_str + esc + "[m"
$ IF .NOT. F$GETDVI ("TT", "TT_DECCRT") THEN prompt = pr_str + "$"
$ SET PROMPT = "''prompt' "

So, if typing an exe or similar occur, one return and most/all is ok again.

YMMV

--
Peter "EPLAN" LANGSTOEGER
Network and OpenVMS system specialist
E-mail pe...@langstoeger.at
A-1030 VIENNA AUSTRIA I'm not a pessimist, I'm a realist

Alan E. Feldman

unread,
Dec 21, 2003, 11:29:29 PM12/21/03
to
pe...@langstoeger.at (Peter 'EPLAN' LANGSTOEGER) wrote in message news:<fnlFb.173783$dt3.1...@news.chello.at>...

> In article <bs433m$2d8$5...@online.de>, hel...@astro.multiCLOTHESvax.de (Phillip Helbig---remove CLOTHES to reply) writes:
> >I'm not saying it's necessarily a good idea, but can one embed escape
> >sequences in the prompt, e.g. to make it appear bold by using the
> >appropriate escape sequences for the terminal in question?
>
> Yes, it is.
>
> I use it for a decade now to restore video attributes or a bad scroll region
> (like EDT which doesn't turn it off on exit but sets it to 24 lines which is
> bad on DECterms with larger sizes).


That EDT problem was fixed at some point somewhere roughly between VMS
v5.5x and 6.1. Is it broken again?


[Code to assemble escape sequences into the symbol "PROMPT" omitted]



> $ SET PROMPT = "''prompt' "


You can use

$ SET PROMPT = &PROMPT

instead. By using the ampersand in this way you can TYPE or PRINT the
command file without sending the actual raw escape sequences to the
terminal or printer. This may also help when running the command file
with SET VERIFY.

Here's what I use to put the node name in bold in the prompt:

$ ESC :=
$ ESC[0,8] = 27
$ BOLD = ESC + "[1m"
$ UNBOLD = ESC + "[0m"
$ NODE = F$GETSYI("NODENAME")
$ PROMPT_STRING = BOLD + NODE + "$" + UNBOLD + " "
$ SET PROMPT = &PROMPT_STRING

[remainder of quoted material cut]

Disclaimer: JMHO
Alan E. Feldman

Peter 'EPLAN' LANGSTOEGER

unread,
Dec 22, 2003, 2:24:27 AM12/22/03
to
In article <b096a4ee.0312...@posting.google.com>, spamsi...@yahoo.com (Alan E. Feldman) writes:
>pe...@langstoeger.at (Peter 'EPLAN' LANGSTOEGER) wrote in message news:<fnlFb.173783$dt3.1...@news.chello.at>...
>> In article <bs433m$2d8$5...@online.de>, hel...@astro.multiCLOTHESvax.de (Phillip Helbig---remove CLOTHES to reply) writes:
>> >I'm not saying it's necessarily a good idea, but can one embed escape
>> >sequences in the prompt, e.g. to make it appear bold by using the
>> >appropriate escape sequences for the terminal in question?
>>
>> Yes, it is.
>>
>> I use it for a decade now to restore video attributes or a bad scroll region
>> (like EDT which doesn't turn it off on exit but sets it to 24 lines which is
>> bad on DECterms with larger sizes).
>
>
>That EDT problem was fixed at some point somewhere roughly between VMS
>v5.5x and 6.1. Is it broken again?

Cool. I haven't noticed (for obvious reasons). But I doubt, that it was V5.5.
It must be around V7 as I waited for it many many years to become fixed (and
I did look for known bugs from my list on [almost] every new VMS version).

>[Code to assemble escape sequences into the symbol "PROMPT" omitted]
>
>> $ SET PROMPT = "''prompt' "
>
>You can use
>
> $ SET PROMPT = &PROMPT
>
>instead. By using the ampersand in this way you can TYPE or PRINT the
>command file without sending the actual raw escape sequences to the
>terminal or printer. This may also help when running the command file
>with SET VERIFY.

SET VERIFY has a difference, TYPE/PRINT has not.
And I prefer using the quotes for debugging reasons (in general; but I must
admit, that this example is one of the very few examples to use the ampersand).

Mike Rechtman

unread,
Dec 22, 2003, 8:00:56 AM12/22/03
to
This is what I use in DECTerms (colour monitor):

$ def = f$envir("DEFAULT")
$ def1 = f$parse(def,,,"DIRECTORY") - "000000" - "][" - "]["- "[" - "]"
$ if def1 .eqs. "" then def1 = f$parse(def,,,"DEVICE")
$ !
$ On = ""


$ ESC[0,8] = 27

$ Off = "''ESC'[0m"
$ if ( lat_terminal .eqs. "FALSE" ) ! DECterm only
$ then
$ On = "''ESC'[33m"
$ if f$priv("SETPRV")
$ then
$ On = "''ESC'[31m"
$ write sys$output "''OSC'2L;*''nodenm'*''ST'"
$ endif
$ else
$ On = "''ESC'[1m"
$ if f$priv("SETPRV") then On = "''ESC'[1m*"
$ endif
$ set prompt="''On'''def1'''Off'_$"
$ exit
$!

Mike
--
---------------------------------------------------------------------
Usual disclaimer: All opinions are mine alone, perhaps not even that.
Mike Rechtman *rech...@tzora.co.il*
Kibbutz Tzor'a. Voice (home): 972-2-9908337
"20% of a job takes 80% of the time, the rest takes another 80%"
---------------------------------------------------------------------
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS d(-)pu s:+>:- a++ C++ U-- L-- W++ N++ K? w--- V+++$
PS+ PE-- t 5? X- tv-- b+ DI+ D-- G e++ h--- r+++ y+++@
------END GEEK CODE BLOCK------

Alan E. Feldman

unread,
Dec 22, 2003, 9:39:13 AM12/22/03
to
pe...@langstoeger.at (Peter 'EPLAN' LANGSTOEGER) wrote in message news:<L_wFb.182116$dt3....@news.chello.at>...

> In article <b096a4ee.0312...@posting.google.com>, spamsi...@yahoo.com (Alan E. Feldman) writes:
> >pe...@langstoeger.at (Peter 'EPLAN' LANGSTOEGER) wrote in message news:<fnlFb.173783$dt3.1...@news.chello.at>...
> >> In article <bs433m$2d8$5...@online.de>, hel...@astro.multiCLOTHESvax.de (Phillip Helbig---remove CLOTHES to reply) writes:
> >> >I'm not saying it's necessarily a good idea, but can one embed escape
> >> >sequences in the prompt, e.g. to make it appear bold by using the
> >> >appropriate escape sequences for the terminal in question?
> >>
> >> Yes, it is.
> >>
> >> I use it for a decade now to restore video attributes or a bad scroll region
> >> (like EDT which doesn't turn it off on exit but sets it to 24 lines which is
> >> bad on DECterms with larger sizes).
> >
> >
> >That EDT problem was fixed at some point somewhere roughly between VMS
> >v5.5x and 6.1. Is it broken again?
>
> Cool. I haven't noticed (for obvious reasons). But I doubt, that it was V5.5.
> It must be around V7 as I waited for it many many years to become fixed (and
> I did look for known bugs from my list on [almost] every new VMS version).

Well, it may not have made it to documentation. And I don't know about
DECterm, but EDT on VMS v6.1 works fine on my SmarTerm except that the
cursor is placed at the bottom of the screen. But that's okay: I still
get my original screen settings back.

> >[Code to assemble escape sequences into the symbol "PROMPT" omitted]
> >
> >> $ SET PROMPT = "''prompt' "
> >
> >You can use
> >
> > $ SET PROMPT = &PROMPT
> >
> >instead. By using the ampersand in this way you can TYPE or PRINT the
> >command file without sending the actual raw escape sequences to the
> >terminal or printer. This may also help when running the command file
> >with SET VERIFY.
>
> SET VERIFY has a difference, TYPE/PRINT has not.

Well, I didn't try it in these specific cases, but in general it is
not a good idea to send escape sequences to terminals or printers. I
have had the "pleasure" of printing some inherited DCL code only to
find the (line) printer get totally messed up, trying to print on the
same region of the paper over and over again (Just what you need: a
scrolling region on a printer!). Only a power cycle would fix it. Of
course I fixed the inherited code so that it wouldn't happen again.

> And I prefer using the quotes for debugging reasons (in general; but I must

Yes, I often do, too.

> admit, that this example is one of the very few examples to use the ampersand).

See

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=b096a4ee.0211121306.772d1334%40posting.google.com&rnum=3

or use

Message-ID: <b096a4ee.02111...@posting.google.com>


to see more uses of the ampersand (warning! url may have wrapped.)

Paul Sture

unread,
Dec 22, 2003, 11:11:36 AM12/22/03
to
Phillip Helbig---remove CLOTHES to reply wrote:
>

Yes, but don't use it in batch mode - it doesn't just make logfiles look
messy but can screw up printers. And beware Murphy - he will have it
that the one time you need to log in remotely to fix something, the only
terminal emulator you have handy will choke.

--
Paul Sture

Tom Wade

unread,
Dec 22, 2003, 11:55:03 AM12/22/03
to

"Phillip Helbig---remove CLOTHES to reply" <hel...@astro.multiCLOTHESvax.de>
wrote in message news:bs433m$2d8$5...@online.de...

> I'm not saying it's necessarily a good idea, but can one embed escape
> sequences in the prompt, e.g. to make it appear bold by using the
> appropriate escape sequences for the terminal in question?

Yes. I use the two enable/disable command procedures below to change the
prompt color when I turn on/off privileges (DECterm).

PICARD-# type loc_com:enable.com
$ ! Command File to enable all privileges and change the prompt
$
$ echo := 'F$Verify (0)'
$ Set Noon
$ esc[0,8]=27
$
$ ! Enable Privileges
$
$ old_privs := 'F$Setprv ("all")'
$ node := 'F$Getsyi ("SCSNODE")'
$
$ If "''enable_prompt'" .eqs. ""
$ Then
$ Set Prompt="''esc'[31m''node'-# ''esc'[0m"
$ Else
$ Set Prompt="''enable_prompt'"
$ EndIf
$
$Finished:
$ echo := 'F$Verify (echo)'

PICARD-# type loc_com:disable.com
$ echo := 'F$Verify (0)'
$ Set Noon
$ esc[0,8]=27
$ junk := 'F$Setprv ("NOALL,TMPMBX,SETPRV,NETMBX")'
$ node := 'F$Getsyi ("scsnode")'
$
$ If "''disable_prompt'" .eqs. ""
$ Then
$ Set Prompt="''esc'[34m''node'-$ ''esc'[0m"
$ Else
$ Set Prompt="''disable_prompt'"
$ EndIf
$
$Finished:
$ echo := 'F$Verify (echo)'

---------------------------------------------------------------
Tom Wade | EMail: tee dot wade at eurokom dot ie
EuroKom | X400: g=tom;s=wade;o=eurokom;p=eurokom;
Unit A2 | a=eirmail400;c=ie
Nutgrove Office Park | Tel: +353 (1) 296-9696
Rathfarnham | Fax: +353 (1) 296-9697
Dublin 14 | Disclaimer: This is not a disclaimer
Ireland | Tip: "Friends don't let friends do Unix !"

William Webb

unread,
Dec 22, 2003, 11:36:31 AM12/22/03
to
pe...@langstoeger.at (Peter 'EPLAN' LANGSTOEGER) wrote in message news:<L_wFb.182116$dt3....@news.chello.at>...

While we're on the subject of things that should perhaps best be
avoided in prompts, here's another one:

Adding three greater than symbols > in a row to one's prompt can fool
some system monitoring software [which shall not be named here] into
thinking that the node has crashed.

WWWebb

========================
William W. Webb- EMS Operations,
OpenVMS Systems Support
USPS DSSC Annex - 4730 Hargrove Road
Raleigh, NC 27616-2874 919.325.7500x4186
* * * -

Barry in Indy

unread,
Dec 22, 2003, 3:27:59 PM12/22/03
to
"Phillip Helbig---remove CLOTHES to reply"
<hel...@astro.multiCLOTHESvax.de> wrote in message
news:bs433m$2d8$5...@online.de...
From my current LOGIN.COM (running QVT/TERM on a Windows PC):
$!
$! Control characters for screen
$! Not all of them work
$!
$ ESC[0,8] == 27
$ CLRSCR == esc + "[1;1H" + esc + "[2J"
$ BOLD == esc + "[1m"
$ RESTORE == esc + "[0m"
$ UNDER == esc + "[4m"
$ BLINK == esc + "[5m"
$ REVER == esc + "[7m"
$!
$! Control characters for color change
$!
$! First number is attribute
$!
$! 0 All off
$! 1 Bold
$! 4 Underscore
$! 5 Blink
$! 7 Reverse
$! 8 Hidden
$!
$! Second number is foreground color
$! Third number is background color
$!
$! COLOR FG BG
$! ----- -- --
$! Black 30 40
$! Red 31 41
$! Green 32 42
$! Yellow 33 43
$! Blue 34 44
$! Magenta 35 45
$! Cyan 36 46
$! White 37 47
$!
$!
$ CPMPT = " [1;33;44m"
$ CPMPT[0,8]=27 ! This puts an escape character in bits 0-7 of
the string

--
Barry in Indy

Knock me out to reply

David J. Dachtera

unread,
Dec 23, 2003, 10:12:56 PM12/23/03
to

Well, as is often the case, there's a large gap between what CAN be done
and what SHOULD be done.

--
David J. Dachtera
dba DJE Systems
http://www.djesys.com/

Unofficial Affordable OpenVMS Home Page:
http://www.djesys.com/vms/soho/

0 new messages