Change/Check your Term Type Quick

For users of /bin/sh or /bin/ksh, functions provide quick, portable alternatives to aliases and shell scripts. Functions also allow you to change environment variables in your current shell quickly and easily.

One of the most common changes you may make is to your TERM variable, especially if you dial into a modem from
various packages (each supporting different emulations). In this case you can use a function to check or change TERM. I call mine "T" since there's no command on my system that uses that name:

T() {
if [ -z "${1}" ]
then
echo "Your TERM type is set to $TERM"
else
echo "Your TERM was $TERM \c"
TERM=${1}
export TERM
echo "and is now $TERM"
fi ;
}

Put this in either your .profile or /etc/profile (so all logins get it). Type "T" alone tells you the term type, while type "T newterm" ("T ansi", for example) will show you what your TERM was and now is.

Caveats to remember: functions do not carry over to sub-shells, so if you shell out of an application the function will not be available. Functions run before any commands in the PATH with the same name, so if there were a /usr/local/bin/T, the function T would run first unless you call "/usr/local/bin/T" directly.

Functions are often used in shell scripts to organize and replicate certain steps, but they are not limited to scripts. This is just one example of how functions can be used. The nice thing about functions is that they are portable between Bourne shell and Korn shell (and their derivatives).

Have a Unix Problem
Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.