add the functions needed for some keybindings
[zsh.git] / .zsh / functions / termsupported
1 # -*- mode:sh -*-
2
3 # termsupported function
4 # Define a useful function to determine if the current value of TERM
5 # is useful, or if it needs changing. Used below.
6 termsupported ()
7 {
8 # terminfo should have a file for this terminal type.
9 if [[ -f "/usr/share/terminfo/$TERM[1]/$TERM" ]]
10 then
11 # If it's there, success.
12 return 0
13 else
14 # With termcap, we have a monolithic terminal type listing.
15 if [[ -f /etc/termcap ]]
16 then
17 # This sed script joins continued \
18 # lines and then checks to see if this terminal name is listed.
19 if [[ "`sed -n \
20 -e '/^$/d' \
21 -e '/^#/d' \
22 -e 'h' \
23 -e 's/^\\([^:\\\\]*\\)[:\\\\].*\$/|\\1|/' \
24 -e '/|'$1'|/p' \
25 -e 'g' \
26 -e ':detail' \
27 -e '/\\$/{' \
28 -e 'n' \
29 -e 'b detail' \
30 -e '}' \
31 < /etc/termcap`" = "" ]]
32 then
33 # Nothing matches, fail.
34 return 1
35 else
36 # Found a matching entry, succeed.
37 return 0
38 fi
39 else
40 # If neither terminal capabilities system was found, fail.
41 return 2
42 fi
43 fi
44 }