3 # capconvert -- automated conversion from termcap to terminfo
6 echo "This script tries to automatically set you up so that your applications"
7 echo "that now use termcap can use terminfo and the ncurses library."
10 # Note, except for telling if we're running under xterm we don't use TERM at
11 # all. This is because BSD users not infrequently have multiple termtypes
12 # selected by conditionals in tset -- unless they're xterm users, in which
13 # case they're on a workstation and probably don't.
15 # Check to make sure TERMINFO is not already defined
18 echo "TERMINFO is already defined in your environment. This means"
19 echo "you already have a local terminfo tree, so you do not need any"
24 # Check to see if terminfo is present.
25 if [ -d /usr/lib/terminfo -o -d /usr/local/lib/terminfo ]
27 echo "Your system already has a system-wide terminfo tree."
30 if [ "$TERMCAP" = "" ]
32 echo "You have no TERMCAP variable set, so we're done."
33 # Assumes the terminfo master covers all canned terminal types
36 if [ "$TERM" = "xterm" ]
38 echo "You're running xterm, which rudely sets TERMCAP itself."
39 echo "We can ignore this, because terminfo knows about xterm."
40 echo "So you'll just use the system-wide terminfo tree."
43 echo "We'll have to make a local one for you anyway, in order"
44 echo "to capture the effect of your TERMCAP variable."
47 echo "No system-wide terminfo tree. We'll make you a local one."
53 # First step -- go find tic
54 set -- `echo $PATH | tr ':' '\n' | sort | uniq`
64 echo "I see tic at $tic."
66 echo "You don't have tic installed anywhere I can see, please fix that."
71 # We have tic. Either there's no system terminfo tree or there is one but
72 # the user has a TERMCAP variable that may modify a stock description.
75 # Make the user a terminfo directory
76 if [ -d $HOME/.terminfo ]
78 echo "It appears you already have a private terminfo directory"
79 echo "at $HOME/.terminfo; this seems odd, because TERMINFO"
80 echo "is not defined. I'm not going to second-guess this -- if you"
81 echo "really want me to try auto-configuring for you, remove or"
82 echo "rename $HOME/terminfo and run me again."
85 echo "I'm creating your private terminfo directory at $HOME/.terminfo"
87 # Ensure that that's where tic's compilation results.
88 # This isn't strictly necessary with a 1.9.7 or later tic.
89 TERMINFO="$HOME/.terminfo"; export TERMINFO
93 # Find a terminfo source to work from
94 if [ -f ../misc/terminfo.src ]
96 echo "I see the terminfo master source is handy; I'll use that."
97 master=../misc/terminfo.src
99 # Ooops...looks like we're running from somewhere other than the
100 # progs directory of an ncurses source tree.
101 master=`find $HOME -name "*terminfo.src" -print`
102 mcount=`echo $master | wc -l`
105 echo "I can't find a terminfo source file anywhere under your home directory."
106 echo "There should be a file called terminfo.src somewhere in your"
107 echo "ncurses distribution; please put it in your home directotry"
108 echo "and run me again (it doesn't have to live there permanently)."
112 echo "I see a file called $master."
113 echo "I'm going to assume this is the terminfo source included with"
114 echo "the ncurses distribution. If this assumption is wrong, please"
115 echo "interrupt me now! OK to continue?"
119 echo "I see more than one possible terminfo source. Here they are:"
120 echo $master | sed "/^/s// /";
123 echo "Please tell me which one to use:"
129 echo "That file doesn't exist. Try again?";
137 # Now that we have a master, compile it into the local tree
138 echo "OK, now I'll make your private terminfo tree. This may take a bit..."
140 # Kluge alert: we compile terminfo.src in two pieces because a lot of machines
141 # with < 16MB RAM choke on tic's core-hog habits.
143 -e '1,/SPLIT HERE/w tsplit$$.01' \
144 -e '/SPLIT HERE/,$w tsplit$$.02' \
146 for x in tsplit$$.*; do $tic -v $x; done
149 echo "You now have a private tree under $HOME/.terminfo;"
150 echo "the ncurses library will automatically read from it,"
151 echo "and ncurses tic will automatically compile entries to it."
153 # We're done unless user has a .termcap file or equivalent named by TERMCAP
154 if [ "$TERMCAP" = "" ]
156 echo "You have no TERMCAP set, so we're done."
159 # OK, here comes the nasty case...user has a TERMCAP. Instead of
160 # trying to follow all the convolutions of the relationship between
161 # TERM and TERMCAP (partly because it's too painful, and partly because
162 # we don't actually know what TERM will be nor even if it always has
163 # the same value for this user) we do the following three steps...
165 if [ -f $HOME/.termcap ]
167 echo 'I see you have a $HOME/.termcap file. I'll compile that.'
170 echo "Note that editing $HOME/.termcap will no longer change the data curses sees."
171 else if `expr $TERMCAP : "/"` = '1'
173 echo "Your TERMCAP names the file $TERMCAP. I'll compile that."
176 echo "Note that editing $TERMCAP will no longer change the data curses sees."
178 echo "Your TERMCAP value appears to be an entry in termcap format."
179 echo "I'll compile it."
180 echo $TERMCAP >myterm$$
184 echo "Note that editing TERMCAP will no longer change the data curses sees."
186 echo "To do that, decompile the terminal decription you want with infocmp(1),"
187 echo "edit to taste, and recompile using tic(1)."
189 # capconvert ends here