#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG  				#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright 2007 - 2015 Christopher Bratusek		#
#							#
#########################################################

HISTCONTROL=$(ini_get history_control)
dbg_msg $"BashStyle-NG Setting:" $"HISTCONTROL" "$HISTCONTROL"

HISTIGNORE="$(ini_get history_ignore)"
dbg_msg $"BashStyle-NG Setting:" $"HISTIGNORE" "$HISTIGNORE"

FIGNORE="$(ini_get completion_ignore)"
dbg_msg $"BashStyle-NG Setting:" $"FIGNORE" "$FIGNORE"

CDPATH=$(ini_get cdpath)
dbg_msg $"BashStyle-NG Setting:" $"CDPATH" "$CDPATH"

FCEDIT=$(ini_get fcedit)
dbg_msg $"BashStyle-NG Setting:" $"FCEDIT" "$FCEDIT"

if [[ $(grep -w TMOUT /etc/profile.d/*msec.sh 2>/dev/null) != "" ]]; then
	ERR_MSG+="\n * /etc/profile.d/msec.sh prevents setting TMOUT!"
else	TMOUT=$(ini_get timeout)
	dbg_msg $"BashStyle-NG Setting:" $"TMOUT" "$TMOUT"
fi

HISTSIZE=$(ini_get history_size)
dbg_msg $"BashStyle-NG Setting:" $"HISTSIZE" "$HISTSIZE"

HISTFILESIZE=$(ini_get history_size)
dbg_msg $"BashStyle-NG Setting:" $"HISTFILESIZE" "$HISTFILESIZE"

if [[ $(ini_get path) != "" ]]; then
	PATH="$(ini_get path)"
	dbg_msg $"BashStyle-NG Setting:" $"PATH" "$PATH"
fi

if [[ $(ini_get colored_grep) == True && $enabcol == True ]]; then \
	dbg_msg $"BashStyle-NG Setting:" $"Colored grep" $"On"
	alias grep="grep --color=auto"
	GREP_COLOR=$(ini_get grep_color);
else	dbg_msg $"BashStyle-NG Setting:" $"Colored grep" $"Off"
fi

export debug_verbose=$(ini_get debug_verbose)

if [[ $(ini_get restore_directory) == True ]]; then
	dbg_log trap 'printf %s "$PWD" > $HOME/.lastpwd' EXIT
	if [[ -e $HOME/.lastpwd && -d "$(cat $HOME/.lastpwd)" ]]; then
		dbg_log cd "$(cat $HOME/.lastpwd)"
	fi
fi

if [[ $(ini_get use_treecd) == True ]]; then
	alias cd=treecd
fi

if [[ $(ini_get use_lscd) == True ]]; then
	alias cd=lscd
	export LSCD_OPTS=$(ini_get lscd_opts)
	if [[ $(ini_get enable_colors) != True ]]; then
		LSCD_OPTS+=" --color=no"
	fi
fi

if [[ $(ini_get dd_noerror) == True ]]; then
	export DD_OPTS="conv=noerror"
fi

export USER_BIRTHDAY=$(ini_get user_birthday)

export pwdmaxlen=$(ini_get pwdlength)
export trunc_symbol=$(ini_get pwdcut)
export dirchar=$(ini_get directory_indicator)

dbg_log export HISTCONTROL HISTIGNORE FIGNORE CDPATH FCEDIT TMOUT HISTSIZE HISTFILESIZE PATH GREP_COLOR
