Συνδεόμενος μέσω SSH σε κάποιο μηχάνημα Solaris από OS X, πάω να ανοίξω τον Vi και βλέπω το παρακάτω μήνυμα:
$:vi xterm-color: Unknown terminal type Visual needs addressable cursor or upline capability :
Στη συνέχεια δοκιμάζοντας με Emacs:
$:emacs emacs: Terminal type xterm-color is not defined. If that is not the actual type of terminal you have, use the Bourne shell command `TERM=... export TERM' (C-shell: `setenv TERM ...') to specify the correct type. It may be necessary to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.
Ο λόγος: το OS X έχει ως προεπιλογμένο τύπο terminal το xterm-color το οποίο το Solaris δεν αναγνωρίζει. Ο τύπος του terminal ορίζεται μέσω της μεταβλητής περιβάλλοντος $TERM. Εάν οριστεί αυτή ως vt100 τότε το Solaris θα είναι και πάλι χαρούμενο:
export TERM=vt100
Για συνεχή χρήση του συγκεκριμένου τύπου terminal μπορεί να προστεθεί ο παραπάνω ορισμό στο .bash_profile του απομακρυσμένου λογαριασμού ή ακόμη καλύτερα να γίνει αλλαγή των προεπιλεγμένων ρυθμίσεων του terminal του OS X:
You might want to keep those colors. There is an ‘xtermc’ terminal type that supports *some* colors in Solaris too.
FWIW, one of the tricks I used in my Solaris-specific “.bashrc” was to run an autoconf-style “config.guess” script that tries auto-detect the system type, and then use something like the following in my “~/.bashrc” file:
cfscript=”$HOME/bin/config.guess”
host=”
if [ -x ${cfscript} ]; then
host=$( ${cfscript} )
fi
case $host in
*sunos*)
case $TERM in
color-xterm*|xterm-color|xterm-[0-9]*color)
export TERM=’xtermc’
;;
esac
# More Solaris-specific bits.
;;
# More OS-specific bits, for other systems.
esac
This tends to keep all the OS-specific tweaks of my .bashrc file more “organized”.
Good point. Based on your suggestion, I did the following and works perfectly with my NIS account that I use to login on both Solaris and Linux hosts:
sys=`uname -s`
if [ $sys == “SunOS” ]; then
case $TERM in
color-xterm*|xterm-color|xterm-[0-9]*color)
export TERM=’xtermc’
;;
esac
else
export TERM=vt100
fi