Improve LANG and TERM selection when missing

This commit is contained in:
Lockszmith (VAST@MacBook) 2025-08-05 09:46:26 -04:00
parent 92f68034aa
commit ff4d5fd7bc

View file

@ -9,7 +9,20 @@ else
[ -z "$UMASK" ] || umask "$UMASK"
export TERM="${TERM:-xterm-256color}"
export LANG="${LANG:-en_US.UTF-8}"
if [ -z "$TERM" ]; then
find /usr/share/terminfo -type f -print0 | xargs -0 basename \
| egrep '^(xterm|vt100|dumb)' | sed -Ee '
s/^(.*)$/9 \1/g;
s/^9 (xterm-256color)/1 \1/;
s/^9 (xterm)$/2 \1/;
s/^9 (vt100-putty)$/3 \1/;
s/^9 (vt100)$/4 \1/;
s/^9 (dumb)/8 \1/;
' | sort | head -n1
fi
if [ -z "$LANG" ] && is_cmd locale; then
export LANG="$(locale -a | egrep -i '^(en_US|C|POSIX)(\.utf-8)?$' | head -n1)"
fi
fi
# vim: set ft=sh expandtab tabstop=4 shiftwidth=4: