Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / konsole / developer-doc / old-documents / More / vt100_colorized_termcap.txt
blob0a5470b45212173a7ac60bb606e961775dedf78b
1 Article 3992 of comp.terminals:
2 Path: cs.utk.edu!gatech!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!msunews!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!newshost.gu.edu.au!news
3 From: Tony Nugent <T.Nugent@sct.gu.edu.au>
4 Newsgroups: comp.terminals
5 Subject: (howto) Set up a custom (colour) vt term
6 Date: 30 Apr 1995 06:35:49 GMT
7 Organization: Griffith University Brisbane Queensland Australia
8 Lines: 371
9 Message-ID: <3nvb45$2kl@griffin.itc.gu.edu.au>
10 Reply-To: T.Nugent@sct.gu.edu.au
11 NNTP-Posting-Host: kraken.itc.gu.edu.au
12 Summary: How to set up a customised term entry
13 Keywords: vt100 vt102 vt220 ansi colour terminfo termcap term
15 G'day all!
17 Here is something that I wrote a little while ago (with some more
18 recent changes) for someone who asked me how to set up a
19 customised TERMINFO and TERMCAP entry.
21 I've never seen this in any FAQ, and I thought that others might
22 be interested in this too, so I've posted it.  It took me *ages*
23 and lots of trial and error to figure out how to do this
24 properly, but the process is actually quite simple once you have
25 the man pages figured out :)
27 I would appreciate any comments, corrections or suggestions to
28 this... I'm posting it here into comp.terminals as a "beta"
29 document as I'm sure that this could be refined some more.
31 ========8<----insert-crowbar-here------------------------------
33 I presume that you understand the basics of ansi and vt-term
34 escape sequences.
36 I use a customised vt220 term to get colours instead of boring
37 black and white text on my pc screen when I'm logged into my
38 account over a modem.  My comms program is emulating vt100/220
39 with my screen in 50 line mode (49 lines + one for my comms
40 program's status line).
42 The system here with my account is a Sparc running Solaris 2.3,
43 SunOS 5.3 - but this also works under SGI IRIX and SunOS 4.3.1
44 (remote vt-term login).  I use tcsh as my default login shell
45 (I'll eventually try out ksh once I have some time :-)
47 Here is my customised termcap entry, produced by the "infocmp -1"
48 command...
50 ========8<-----------cut-here------------>8====================
51 #       Reconstructed via infocmp from file: /home/tnugent/.terminfo/v/vt220
52 vt220|vt-220|dec colour vt220,
53         xon,
54         cols#80, lines#49, vt#3,
55         bel=^G, blink=\E[5m$<2>, bold=\E[1m\E[32;44m$<2>,
56         clear=\E[;H\E[2J$<50>, cnorm=\E[?7h\E[0;2;1;36m,
57         cr=\r, csr=\E[%i%p1%d;%p2%dr, cub1=\b, cud1=\n,
58         cuf1=\E[C$<2>, cup=\E[%i%p1%d;%p2%dH$<5>,
59         cuu1=\E[A$<2>, cvvis=\E[?7l, ed=\E[J$<50>,
60         el=\E[K$<3>, home=\E[H, ht=\t, ind=\n,
61         is2=\E[1;49r\E[49;1H, kbs=\b, kcub1=\EOD, kcud1=\EOB,
62         kcuf1=\EOC, kcuu1=\EOA, kf0=\E[29~, kf1=\EOP,
63         kf10=\E[29~, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[17~,
64         kf6=\E[18~, kf7=\E[19~, kf8=\E[20~, kf9=\E[21~,
65         rc=\E8, rev=\E[7m$<2>, ri=\EM$<5>, rmacs=\E(B$<4>,
66         rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[7m\E[0;1;36m$<2>,
67         rmul=\E[m\E[0;1;36m$<2>,
68         rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E1;36m\E[?8h, sc=\E7,
69         sgr0=\E[m\E[1;36m$<2>, smkx=\E[?1h\E=,
70         smso=\E[m\E[1;33;44m$<2>, smul=\E[4m\E[1;32m$<2>,
71 ========8<-----------cut-here------------>8====================
73 For the explaination of what all this means, see "man terminfo";
74 also try "man termcap", but this man page is often not there.
76 It's set for a default of 49 lines, but if you only use 24 then
77 change it in the entry, but I'll explain how to easily reset it
78 manually with some aliases.
80 Otherwise edit this however you like.  You'll recognise all the
81 "ansi" escape sequences up there.  Customise the colour ones as
82 desired, but after trial and error I've found these to be quite
83 acceptable.  Some of the entries might need some more refining,
84 but this works.  Bold, underline, reverse and norm are all in
85 colour.  I've thought about adding an entry for italic (sitm and
86 ritm), but I haven't got around to this yet.
88 I've called this "vt220", but it really isn't (although
89 compatable).  I've found it better to use a "common" name rather
90 than an unusual one, or else I tend to get "unknown term type,
91 using dumb terminal settings" complaints when I rlogin or telnet
92 into other accounts.
94 vt220 is defined in /etc/termcap here as:
96 de|vt220|DEC VT220 in vt100 emulation mode:\
97         :tc=vt100:
99 so vt220 actually uses vt100 anyway.  They are similar, but vt220
100 defines more of the F (function) keys.  Other differences are
101 trivial (and I haven't noticed many from what I've been able to
102 ascertain from a scattering of "non-authoritative" sources).
104 Create a ~/.terminfo/ directory, and save this terminfo entry in
105 a file called ~/.terminfo/terminfo.src
107 Now change to this directory and append the other terminal
108 entries that you might use onto the end of this file (except for
109 vt220):
111 % echo $term
112 % infocmp >> terminfo.src
113 % infocmp vt100 >> terminfo.src
114 % infocmp xterm >> terminfo.src
116 etc.  Check it's general format what you find in /etc/termcap to
117 make sure that it's similar.
119 Now do this (in the ~/.terminfo/ directory):
121 % setenv TERMINFO ~/.terminfo
122 % tic
124 After running tic (it uses the terminfo.src file), you should see
125 a new directory called ~/.terminfo/v/ (and perhaps others) which
126 has the termcap entries compiled from the terminfo.src file.
128 Now, do this:
130 % set term=vt220
132 You *should* immediately see a change in colour of normally white
133 (or grey) text to a light bright blue (see "norm=" above).  If
134 you have tcsh as your shell, then try the prompts below to see
135 some nice bold and reverse colour.  Man pages should now also
136 demostrate this too (especially if you have setenv PAGER "less -s
137 -I").  Nice change, eh?  :-)
139 Ok, now to make this change permanent...
141 Cut this shell script out, save it in ~/.terminfo/maketc and
142 "chmod +x maketc" to make it executable:
144 ========8<-----------cut-here------------>8====================
145 #!/bin/sh
147 # Make a TERMCAP entry
149 # Use:
150 #    maketc [termtype] 
152 # setenv TERMCAP `maketc [termtype]`
154 # There's probably a better way to do this
156 infocmp -C $1 | \
157   sed -e '/^#/d' -e '3,$s/[      ]//g' -e 's/:\\$//' | \
158   awk '{printf("%s",$0)}'
159 echo ""
160 # NB: that's a Tab and a space in between the []'s!
161 # Is there a way to get sed to strip out newlines?
162 ========8<-----------cut-here------------>8====================
164 Now try this (using this new term setting):
166 % maketc
168 Ugly, yes?  :)
170 Create a ~/.terminfo/TERMCAP.vt220 file by redirecting this output:
172 % maketc vt220 > TERMCAP.vt220
174 (alternatively, use " setenv TERMCAP `cat ~/.terminfo/maketc` "
175 below instead).
177 Put the following lines in your ~/.login file, or into another
178 file (say, ~/.termrc) and source it from ~/.login...
180 ========8<-----------cut-here------------>8====================
181 # Please customise this!
183 if ( ! $?term ) then
184   set term=vt102
185   setenv TERM vt102
186 endif
188 switch($term)
190   case 'vt220':
191   case 'vt102':
192     stty rows 49
193     stty columns 80
194     setenv LINES 49
195     setenv COLUMNS 80
196     echo Assuming \($term with $LINES rows\)
197     breaksw
198   case 'vt100':
199     stty rows 24
200     stty columns 80
201     setenv LINES 24
202     setenv COLUMNS 80
203     breaksw
204   case 'xterm':
205     eval `/usr/openwin/bin/resize`
206     stty rows $LINES
207     stty cols $COLUMNS
208   default:
209     breaksw
210 endsw
212 # Set colour if on a vt100, vt102 or vt220
214 if ( $TERM == vt102 || $TERM == vt100 || $TERM == vt220 ) then
215   setenv TERMINFO ~/.terminfo
216   set term=vt220
217   setenv TERM vt220
218   setenv TERMCAP `cat ${TERMINFO}/TERMCAP.vt220`
219   # setenv TERMCAP `~/.terminfo/maketc`
220 endif
222 # Set variables: NORM BOLD OFFBOLD ULINE OFFULINE REV
224 setenv NORM `tput cnorm`
225 setenv REV `tput rev`
226 setenv BOLD `tput smso`
227 setenv OFFBOLD `tput smso`
228 setenv ULINE `tput smul`
229 setenv OFFUL `tput rmul`
231 echo ""
232 echo "${BOLD}TERMINFO is now: $NORM$TERMINFO"
233 echo "${BOLD}TERMCAP  is now: $NORM"
234 echo "$TERMCAP"
235 echo ""
237 echo -n "${ULINE}"\$TERM"$NORM is $BOLD $TERM $NORM and "
238 echo    "${ULINE}"\$term"$NORM is $BOLD $term ${NORM}"
239 echo -n "$BOLD $LINES $NORM ${ULINE}rows${NORM} "
240 echo    "$BOLD $COLUMNS $NORM ${ULINE}columns${NORM}"
241 echo ""
243 echo -n "${REV}reverse${NORM}  "
244 echo -n "${BOLD}bold${NORM}  "
245 echo -n "${ULINE}underline${OFFUL} "
246 echo "$NORM"
247 echo -n "${REV}${BOLD} reverse-bold ${NORM} "
248 echo -n "${REV}${ULINE} reverse-underline ${NORM} "
249 echo -n "${BOLD}${ULINE} bold-underline ${NORM} "
250 echo -n "${REV}${BOLD}${ULINE} reverse-bold-underline ${NORM} "
251 echo ""
253 echo -n tset:
254 /usr/ucb/tset -I -Q -
256 ========8<-----------cut-here------------>8====================
258 It's a bit overdone, but it will show you what's going on.
259 Warnings.... on some unix'es, stty does not have "rows" or
260 "columns" options.  And if you ever use those global variables
261 for anything, enclose the variables in quotes like I have above.
263 Next time you log in (with csh or tcsh), ~/.login is sourced
264 (after ~/.cshrc) and you will automatically have this customised
265 colour terminal enabled.
267 To make switching term very easy, I use a few aliases.  I have
268 the following in a ~/.alias file that I source from ~/.cshrc...
270 ========8<-----------cut-here------------>8====================
271 # ~/.alias
272 # sourced from ~/.cshrc
273 #...
274 #...
276 #-------- Terminal setup ------------
278 a cls           'clear'
279 a seterm        'setenv TERM \!:1 ; set term=\!:1'
280 a vt102         'unsetenv TERMINFO ; unsetenv TERMCAP ; seterm vt102'
281 a vt220         'colour'
282 a colour        'setenv TERMINFO ~/.terminfo ; \
283                 setenv TERMCAP `cat ${TERMINFO}/TERMCAP` ; seterm vt220'
284 a rows          'stty rows \!:1    ; setenv LINES \!:1   ; cols 80'
285 a cols          'stty columns \!:1 ; setenv COLUMNS \!:1 '
286 a setsize       'rows \!:1 ; echo $LINES line mode'
287 a 49            'setsize 49'
288 a 50            '49'
289 a 24            'setsize 24'
290 a 25            '24'
292 a vtn           'echo -n "^[[m^[(B^[)0^O^[[?5l^[7^[[r^[8"'
293 #                         ^^  ^^  ^^  ^^^^    ^^ ^^  ^^
294 #                         Esc Esc  Esc Ctrl-O EscEsc Esc
295 # If the vtn alias doesn't work correctly, then try this:
296 # a vtn         'echo "X[mX(BX)0OX[?5lX7X[rX8" | tr '\''XO'\'' '\''\033\017'\'''
299 #... other aliases ...
300 ========8<-----------cut-here------------>8====================
302 The vtn alias has been piped through cat -v to make the control
303 codes look like their two-character representation.  Edit the
304 echo'ed string so that the ^[ characters are real escape
305 characters and ^O is a control-O.  Or comment out that line and
306 use the one below it that uses the tr command.  This alias is
307 very, VERY handy for resetting a vt100 style screen if it gets
308 screwed up with an accidental character set sequence (see any
309 vt100 term escape code reference).
311 If you want to see some interesting colourful prompts and you use
312 tcsh, then try sourcing this:
314 ========8<-----------cut-here------------>8====================
315 # Primary tcsh command prompt
317 # simple looking one
318 # set prompt='$S%?%s %B%/-%b%U%h%u-%U%#%u%L'
320 # set prompt='%S%l%s|%U%?%u[%B%t%b]%S%~%s-%B%h%b-%U%#%u%L'
321 # set prompt='%u%s%b[%U%m%u|%U%~%u][%S%t%s][%B%h%b][%S%?%s]%U-%#%u%L'
322 # set prompt='%B%b[%S%?%s][%S%t%s][%B%h%b][%U%m%u|%U%~%u]%U-%#%u%L'
323   set prompt='%B%b[%S%?%s][%U%t%u][%S%m%s|%S%~%s][%B%h%b]%U-%#%u%L'
325 # prompt2
326 # Used wherever normal csh prompts with a question mark.
328 # set prompt2='%B%R?>%b '
329   set prompt2='%B%R%b%S?%s%L'
331 # prompt3
332 # Used  when displaying  the  corrected command line when automatic
333 # spelling correction is in effect.
335 # set prompt3='CORRECT>%R (y|n|e)?'
336 # set prompt3='%BCORRECT%b%S>%s%R (%By%b|%Bn%b|%Be%b)%S?%s%L'
337   set prompt3='%{\e[41;33;5m%}CORRECT%S>%s%R (%By%b|%Bn%b|%Be%b)%S?%s%L'
338 ========8<-----------cut-here------------>8====================
340 Note how the red colour is manually put into prompt3.  It's
341 possible to put colour sequences into the prompts of all the
342 common shells (check its man page).
344 For more info check out:
346 1. The man pages for:
347         terminfo, (termcap), stty, tput, infocmp, captoinfo, tic
348         (and the man pages in the "see also" sections).
350 2. The file /etc/termcap
352 3. The comp.terminals ftp archive site:
353         cs.utk.edu :: /pub/shuford/terminal/
354    You should be able to find at least one file there that
355    explains all the vt100 control sequences.
357 4. I've got a file with the vt102 and ansi escape sequences in it.
358    If you want a copy, just let me know.
360 5. I've never seen it, but for a color xterm check this out:
361         X11R5 and X11R6 versions:
362         ftp.x.org       /R5contrib/color_xterm.tar.Z
363         ftp.x.org       /contrib/utilities/color-xterm-R6-patch.README
364         ftp.x.org       /contrib/utilities/color-xterm-R6pl5-patch.gz
365         ftp.x.org       /contrib/utilities/colour_xterm.tar.gz
367 Enjoy!
369 Tony
370 T.Nugent@sct.gu.edu.au
371 04/23/95
372 ========8<----insert-crowbar-here------------------------------
374 All comments very much appreciated.
376 Cheers
377 Tony
378         MMM             \|/              www              __^__
379        (o o)            @ @             (o o)            /(o o)\
380   -.ooO-(_)-Ooo.-+-.oOO-(_)-OOo.-+-.oOO--(_)--OOo.-+-.oOO==(_)==OOo.-----+
381   |    Tony Nugent  |-| Griffith University  T.Nugent@sct.gu.edu.au      |--.
382   |     __'!`__     | | Brisbane, Queensland tnugent@gucis.cit.gu.edu.au |  |
383   |      (o o)      | | Australia                                        |  |
384   `-ooO---(=)---Ooo-' `--------------------------------------------------'  |
385     `------------------' `--------------------------------------------------'
388 Article 3993 of comp.terminals:
389 Path: cs.utk.edu!gatech!swrinde!hookup!news.moneng.mei.com!uwm.edu!msunews!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!newshost.gu.edu.au!news
390 From: Tony Nugent <T.Nugent@sct.gu.edu.au>
391 Newsgroups: comp.terminals
392 Subject: Re: (howto) Set up a custom (colour) vt term
393 Date: 30 Apr 1995 07:17:03 GMT
394 Organization: Griffith University Brisbane Queensland Australia
395 Lines: 35
396 Message-ID: <3nvdhf$36j@griffin.itc.gu.edu.au>
397 References: <3nvb45$2kl@griffin.itc.gu.edu.au>
398 Reply-To: T.Nugent@sct.gu.edu.au
399 NNTP-Posting-Host: kraken.itc.gu.edu.au
400 Keywords: vt100 vt102 vt220 ansi colour terminfo termcap term
402 Tony Nugent <T.Nugent@sct.gu.edu.au> writes:
404 Sorry about this:
406 [munch]
408 >To make switching term very easy, I use a few aliases.  I have
409 >the following in a ~/.alias file that I source from ~/.cshrc...
411 >========8<-----------cut-here------------>8====================
412 ># ~/.alias
413 ># sourced from ~/.cshrc
414 >#...
416 alias a         'alias'
418 >#...
420 >#-------- Terminal setup ------------
422 >a cls          'clear'
423 >a seterm       'setenv TERM \!:1 ; set term=\!:1'
425 [munch]
427 I forgot to mention that I have the alias command aliased to "a".
429 Cheers
430 Tony
431     /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/~\
432    | Tony Nugent  Griffith University, Brisbane, Queensland, Australia| _ |
433    |      Email:  T.Nugent@sct.gu.edu.au  tnugent@gucis.cit.gu.edu.au | @||
434     \__________________________________________________________________\_/|
435     /  Pull here for the full .sig or use finger on the second address   /
436     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~