# $MirSecuCron$
# $MirOS: src/etc/profile,v 1.66 2009/11/15 11:49:17 tg Exp $

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/mpkg/bin
umask 022
[ -z "$KSH_VERSION$ZSH_VERSION" ] && alias print='echo -e'
: ${HOME:=/} ${OSNAME:=MirBSD}
export HOME PATH
[ -s "$HOME/.profile.preinit" ] && . $HOME/.profile.preinit

[ -z "$TERM" -o x"$TERM" = x"unknown" ] && if [ -x /usr/bin/tset ]; then
	x=$(ulimit -c 0; /usr/bin/tset -sQ \?vt220)
	TERM=vt100
	eval $x
else
	TERM=vt220
fi
stty newcrt werase '^W' intr '^C' kill '^U' erase '^?' status '^T'

if [ -n "$USER" ]; then
	PATH=~/.etc/bin:/usr/local/bin:/usr/mpkg/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/sbin:/sbin:/usr/mpkg/sbin:/usr/games
	PS1='$ '
fi
_shellok=
BROWSER=lynx
CVSUMASK=002
EDITOR=/bin/ed
IRCNAME="MirOS packages a kernel, userland and the attitude"
IRCPORT=6667
IRCSERVER=irc.eu.freenode.net
LC_CTYPE=en_US.UTF-8
PAGER=/usr/bin/less
if [ -n "$KSH_VERSION" ]; then
	test -z "$USER" || PS1="\$PWD $PS1"
	alias which='whence -p'
	_shellok=1
elif [ -n "$BASH_VERSION" ]; then
	set -o emacs
	shopt -s extglob
	[[ $TERM = screen ]] && \
		X_COLOUR=$X_COLOUR'[1;36;40m\]screen:\['
	if [[ $OSTYPE = linux-gnu || $OSTYPE = Linux ]]; then
		# compat_linux(8)
		PS1='\['$X_COLOUR'[31m\]Linux!\[[0m\]\u@\h:\w \$ '
		[[ -e /emul/linux/bin/ls ]] && alias ls='/bin/ls --color'
	else
		# native via ports
		PS1='\['$X_COLOUR'[34m\]bash!\[[0m\]\u@\h:\w \$ '
	fi
	[[ -n $NOCOLOURPROMPT ]] && PS1='bash:\u@\h:\w \$ '
	_shellok=1
elif [ -n "$ZSH_VERSION" ]; then
	PS1='%n@%m:%~ %# '
	if [[ -n $NOCOLOURPROMPT ]]; then
		PS1='zsh:'$PS1
		RPS1='%(?..%?)'
	else
		PS1='%B%F{4}zsh!%f%b'$PS1
		RPS1='%(?..%B%F{1}%?%f%b)'
	fi
	_shellok=1
fi
XDG_CACHE_HOME=$HOME/.etc/xdg/cache
XDG_CONFIG_HOME=$HOME/.etc/xdg/config
XDG_DATA_HOME=$HOME/.etc/xdg/data
export BROWSER CVSUMASK EDITOR HOME IRCNAME IRCPORT IRCSERVER LC_CTYPE OSNAME
export PAGER PS1 TERM XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME
unset HISTFILE NOCOLOURPROMPT x
test -n "$_shellok" || return 0
unset _shellok
[[ -n $KSH_VERSION$ZSH_VERSION ]] && alias cls='print -n \\033c'
# convenience aliases and functions:
[[ -x /emul/linux/bin/bash ]] && alias lx='/emul/linux/bin/bash --login'
function bye {
	[[ $1 = k ]] && ssh-agent -k
	typeset M='\033c'
	[ $? -ne 0 ] && M='\033c Warning: ssh-agent returned error!\n'
	print -n -- "$M"
	exit
	logout
}
function ge {		# German ⇄ English
	$BROWSER "http://dict.leo.org/?search=$*"
}

if [ -O /var/run/ssh-agent/$USER_ID ]; then
	_dir=/var/run/ssh-agent/$USER_ID
	# If the agent is not running, remove stale files
	[[ -e $_dir/socket ]] || rm -f $_dir/{agent,keyread}
	# Start ssh-agent if it is not already started
	[[ -e $_dir/agent || -S $SSH_AUTH_SOCK ]] || \
	    (cd /; ssh-agent -s -a $_dir/socket) >$_dir/agent
	# Do the following only if ssh-agent is running
	if [[ -e $_dir/socket ]]; then
		# Read configuration file if it exists
		[[ -s $_dir/agent ]] && . $_dir/agent >&2
		# Read in the keys, if not already done
		[[ -e $_dir/keyread ]] || ssh-add | tee $_dir/keyread
	fi
	unset _dir
fi

: $MirOS: src/etc/profile,v 1.66 2009/11/15 11:49:17 tg Exp $
