#!/bin/sh
# source this file:
#  . /usr/local/share/x-lt/profile
# if you want to override what this scripts sets, use:
# FORCE_LANG=lt_LT.ISO_8859-4; or FORCE_LANG=lt_LT.UTF-8;
# export FORCE_LANG

# On some systems this can have odd values and override LANG:
unset LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_MESSAGES LC_NUMERIC LC_TIME

# Set erase character to what backspace key sends (Backspace)
test ! -t 0 || stty erase ^H

#	if [ _${TERM##linux*} = _ ]; then
#		if [ _${LANG##*.[Uu][Tt][Ff]-8} = _ ]; then
##	switch keyboard and console to Unicode mode
#			kbd_mode -u; printf '\033\045G\033(K'
#		else
##	switch keyboard and console to ascii mode and user-defined map
#			kbd_mode -a; printf '\033\045@\033(K'
#			[ _$TERM = _linux ] && tty="`tty`" && [ _${tty%%/dev/tty[0-9]*} = _ ] && TERM=linux+k
#		fi
#	fi

[ _$TERM = _linux ] && tty="`tty`" && [ _${tty%%/dev/tty[0-9]*} = _ ] && TERM=linux+k

if [ "$FORCE_LANG" = lt_LT.UTF-8 ] || { [ -z "$FORCE_LANG" -a _$TERM != _ ] && [ _${TERM##*+utf8} = _ -o _$TERM = _uterm -o _$TERM = _uxterm -o _$TERM = _9term ]; } then
	if [ _${TERM##linux*} = _ ]; then
#	switch keyboard and console to Unicode mode
		kbd_mode -u;
		reset -Q || printf '\033\045G\033(K'
	fi
	LANG=lt_LT.UTF-8
	MM_CHARSET=UTF-8
	MANOPT=-7${MANOPT##-} # don't use latin1 charactes and display all pages
	LESS="-CMij7 -rz-4"

else
	if [ _${TERM##linux} != _$TERM ]; then
#	switch keyboard and console to ascii mode and user-defined map
		kbd_mode -a; printf '\033\045@\033(K'
	fi
	LANG=lt_LT.ISO_8859-4
	MM_CHARSET=ISO-8859-4
	LESS="-Mij7 -z-4"

#	<ESC> - D is ISO 2022 code to switch kterm to ISO 8859-4 charset.
	[ "$TERM" = "kterm" ] && printf '\033-D'

fi
# in case you isprint() is broken:
LESSCHARSET=koi8-r

test -n "$XENVIRONMENT" || XENVIRONMENT="/usr/local/share/x-lt/Xresources"
test -n "$IGNOREEOF" || IGNOREEOF=12 # Prevents bash exiting on EOF (Ctrl-D)
export LANG LESS LESSCHARSET MM_CHARSET MANOPT XENVIRONMENT

if test -n "$BASH"; then

#function dt { date +"%c %Z (%z)" "$@"; } #for Linux
#function dt { date +"%+" "$@"; } #for BSD
#function l { ls -l "$@" ; }
#function ls { command ls -F --literal "$@" ; } # --literal is only on Linux
mc () {
	      MC=/tmp/mc$$-"$RANDOM"
	      mc=midc
	      [ "`type -p -a mc`" != "" ] && mc=mc
	      command $mc -P "$@" > "$MC"
	      cd `cat "$MC"`
	      rm "$MC"
	      unset MC mc
}
pstree () {
	if [ "${LANG%%*.[Uu][Tt][Ff]*}_" = _ ]
	then command pstree -achlpuUn "$@"
	else command pstree -achlpun "$@"
	fi
}
export -f mc pstree

fi

unset FORCE_LANG

