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

if [[ ${TERM} != *xterm* ]]; then
	return_good="+"
	return_bad="-"
	return_other="/"
else
	[[ -n $(ini_get return_good) ]] && return_good="$(ini_get return_good)" || return_good="✔"
	[[ -n $(ini_get return_bad) ]] && return_bad="$(ini_get return_bad)" || return_bad="✘"
	[[ -n $(ini_get return_other) ]] && return_other="$(ini_get return_other)" || return_other="⊘"
fi

lastcommand=""
lastcommandprintable="                     "
lastexit=0

bashstyle_remember_command_debug () {
	local _lastexit=$?
	[[ "${BSNG_TRAP_RECORD}" != True ]] && return
	[ -n "$COMP_LINE" ] && return
	[ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return
	[[ "$BASH_COMMAND" == trap\ * ]] && return
	[[ "$BASH_COMMAND" == *lastcommand* ]] && return
	[[ "$BASH_COMMAND" == *lastexit* ]] && return

	local X_COMMAND=${BASH_COMMAND//$'\n'/ }
	X_COMMAND=${X_COMMAND//\\n/ }

	lastcommand=${BASH_COMMAND}
	lastcommandprintable=${X_COMMAND:0:21}

	if [ ${#lastcommandprintable} -gt 21 ]; then
		lastcommandprintable=${lastcommandprintable:0:20}'>'
	else
		lastcommandprintable="$(printf '%-21s' "$lastcommandprintable")"
	fi

	lastexit=${_lastexit}
}

bashstyle_remember_command_error () {
	local _lastexit=$?
	[[ "${BSNG_TRAP_RECORD}" != True ]] && return
	lastexit=${_lastexit}
}
