smart spacing management

This commit is contained in:
nojhan 2012-07-19 11:14:42 +02:00
parent 5ee7e864a9
commit ba65cd24fd

View File

@ -399,17 +399,48 @@ __return_value()
fi
}
# space right
__sr()
{
if [ ! -z "$1" ] ; then
echo -n "$1<"
fi
}
# space left
__sl()
{
if [ ! -z "$1" ] ; then
echo -n ">$1"
fi
}
# space both
__sb()
{
if [ ! -z "$1" ] ; then
echo -n "=$1="
fi
}
__set_bash_prompt()
{
__RETURN="`__return_value $?`"
__LOAD="`__load_color`"
__JOBS="`__jobcount_color`"
__BATT="`__battery_color`"
__GIT="`__git_branch_color`"
__HG="`__hg_branch_color`"
__SVN="`__svn_branch_color`"
# left of main prompt
__JOBS=$(__sr "`__jobcount_color`")
__LOAD=$(__sr "`__load_color`")
__BATT=$(__sr "`__battery_color`")
# in main prompt
__HOST="`__host_color`"
__PROMPT="`__smart_mark`"
# right of main prompt
__GIT=$(__sl "`__git_branch_color`")
__HG=$(__sl "`__hg_branch_color`")
__SVN=$(__sl "`__svn_branch_color`")
__RET=$(__sl "`__return_value $?`")
__MARK=$(__sb "`__smart_mark`")
PS1="${__BATT}${__LOAD}${__JOBS}"
if [ "$EUID" -ne "0" ]
then
@ -418,7 +449,7 @@ __set_bash_prompt()
else
PS1="${PS1}[${LIGHT_YELLOW}\u${__HOST}${NO_COL}:${YELLOW}\w${NO_COL}]"
fi
PS1="${PS1}${__RETURN}${__PROMPT} "
PS1="${PS1}${__RET}${__MARK}"
# Glue the bash prompt always go to the first column .
# Avoid glitches after interrupting a command with Ctrl-C