Major fix for brackets in terminal multiplexer

Optimize terminal multiplexer detection by moving it to the initial
loading instead of at each prompt display: the terminal multiplexer is
always a parent process and that can not change during the shell life.

This also fixes a major leak: LP_MARK_BRACKET_OPEN was growing at each
prompt display when running in a terminal multiplexer.
(check with: echo "$LP_MARK_BRACKET_OP" | od -c )
This commit is contained in:
Olivier Mengué 2013-05-04 15:15:26 +02:00
parent 9daaaa9f4f
commit 2aaf7bb002

View File

@ -321,6 +321,12 @@ unset _lp_source_config
[[ "$LP_ENABLE_BZR" = 1 ]] && { command -v bzr > /dev/null || LP_ENABLE_BZR=0 ; }
[[ "$LP_ENABLE_BATT" = 1 ]] && { command -v acpi >/dev/null || LP_ENABLE_BATT=0 ; }
# If we are running in a terminal multiplexer, brackets are colored
if [[ "$TERM" == screen* ]]; then
LP_MARK_BRACKET_OPEN="${LP_COLOR_IN_MULTIPLEXER}${LP_MARK_BRACKET_OPEN}${NO_COL}"
LP_MARK_BRACKET_CLOSE="${LP_COLOR_IN_MULTIPLEXER}${LP_MARK_BRACKET_CLOSE}${NO_COL}"
fi
# Escape the given strings
# Must be used for all strings that may comes from remote sources,
# like VCS branch names
@ -644,13 +650,6 @@ _lp_jobcount_color()
}
# Tells if we are running in a terminal multiplexer
_lp_in_multiplexer()
{
[[ "$TERM" == screen* ]]
}
# Display the return value of the last command, if different from zero
_lp_return_value()
{
@ -1375,10 +1374,6 @@ _lp_set_prompt()
LP_TIME=$(_lp_sr "$(_lp_time)")
# in main prompt: no space
if _lp_in_multiplexer ; then
LP_MARK_BRACKET_OPEN="${LP_COLOR_IN_MULTIPLEXER}${LP_MARK_BRACKET_OPEN}${NO_COL}"
LP_MARK_BRACKET_CLOSE="${LP_COLOR_IN_MULTIPLEXER}${LP_MARK_BRACKET_CLOSE}${NO_COL}"
fi
LP_PROXY="$(_lp_proxy)"
# right of main prompt: space at left