Add case for screen title escape chars

This commit is contained in:
Nicolas LACOURTE 2013-03-08 01:59:06 +01:00
parent 4a64c6ccec
commit 2296081d01
2 changed files with 12 additions and 3 deletions

View File

@ -274,6 +274,8 @@ Special characters:
* `LP_MARK_BRACKET_CLOSE` (default: "]") marks around the main part of the prompt * `LP_MARK_BRACKET_CLOSE` (default: "]") marks around the main part of the prompt
* `LP_TITLE_OPEN` (default: "\e]0;") escape character opening a window's title * `LP_TITLE_OPEN` (default: "\e]0;") escape character opening a window's title
* `LP_TITLE_CLOSE` (default: "\a") escape character closing a window's title * `LP_TITLE_CLOSE` (default: "\a") escape character closing a window's title
* `LP_SCREEN_TITLE_OPEN` (default: "\033k") escape character opening screen window's title
* `LP_SCREEN_TITLE_CLOSE` (default: "\033\134") escape character closing screen window's title
## KNOWN LIMITATIONS AND BUGS ## KNOWN LIMITATIONS AND BUGS

View File

@ -197,6 +197,8 @@ _lp_source_config()
LP_PS1_PREFIX=${LP_PS1_PREFIX:-""} LP_PS1_PREFIX=${LP_PS1_PREFIX:-""}
LP_TITLE_OPEN=${LP_TITLE_OPEN:-"\e]0;"} LP_TITLE_OPEN=${LP_TITLE_OPEN:-"\e]0;"}
LP_TITLE_CLOSE=${LP_TITLE_CLOSE:-"\a"} LP_TITLE_CLOSE=${LP_TITLE_CLOSE:-"\a"}
LP_SCREEN_TITLE_OPEN=${LP_SCREEN_TITLE_OPEN:-"\033k"}
LP_SCREEN_TITLE_CLOSE=${LP_SCREEN_TITLE_CLOSE:-"\033\134"}
LP_ENABLE_PERM=${LP_ENABLE_PERM:-1} LP_ENABLE_PERM=${LP_ENABLE_PERM:-1}
LP_ENABLE_SHORTEN_PATH=${LP_ENABLE_SHORTEN_PATH:-1} LP_ENABLE_SHORTEN_PATH=${LP_ENABLE_SHORTEN_PATH:-1}
@ -1134,8 +1136,14 @@ _lp_title()
# Use it in the window's title # Use it in the window's title
# Escapes whill tells bash to ignore the non-printing control characters when calculating the width of the prompt. # Escapes whill tells bash to ignore the non-printing control characters when calculating the width of the prompt.
# Otherwise line editing commands will mess the cursor positionning # Otherwise line editing commands will mess the cursor positionning
case "$TERM" in
xterm*|rxvt*)
local title="${_LP_OPEN_ESC}${LP_TITLE_OPEN}${txt}${LP_TITLE_CLOSE}${_LP_CLOSE_ESC}" local title="${_LP_OPEN_ESC}${LP_TITLE_OPEN}${txt}${LP_TITLE_CLOSE}${_LP_CLOSE_ESC}"
;;
screen*)
local title="${_LP_OPEN_ESC}${LP_SCREEN_TITLE_OPEN}${txt}${LP_SCREEN_TITLE_CLOSE}${_LP_CLOSE_ESC}"
;;
esac
echo -n "${title}" echo -n "${title}"
} }
@ -1314,7 +1322,6 @@ _lp_set_prompt()
PS1="${PS1}${LP_ERR}${LP_MARK}" PS1="${PS1}${LP_ERR}${LP_MARK}"
# "invisible" parts # "invisible" parts
# Get the current prompt on the fly and make it a title # Get the current prompt on the fly and make it a title
LP_TITLE=$(_lp_title "$PS1") LP_TITLE=$(_lp_title "$PS1")