Skip to content

Commit

Permalink
Break out _lp_multiplexer() function and theme
Browse files Browse the repository at this point in the history
The brackets for the default theme are colored when in a multiplexer, so
break that out of lp_activate() and put it in _lp_theme_activate().
  • Loading branch information
Rycieos committed Nov 25, 2020
1 parent c946155 commit 0200b99
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions liquidprompt
Original file line number Diff line number Diff line change
Expand Up @@ -440,17 +440,13 @@ lp_activate() {
# Use standard path symbols inside Midnight Commander
[[ -n "${MC_SID-}" ]] && LP_ENABLE_SHORTEN_PATH=0

# If we are running in a terminal multiplexer, brackets are colored
if [[ "$TERM" == screen* || -n ${TMUX-} ]]; then
LP_BRACKET_OPEN="${LP_COLOR_IN_MULTIPLEXER}${LP_MARK_BRACKET_OPEN}${NO_COL}"
LP_BRACKET_CLOSE="${LP_COLOR_IN_MULTIPLEXER}${LP_MARK_BRACKET_CLOSE}${NO_COL}"
# If we are running in a terminal multiplexer, special title escapes
if _lp_multiplexer; then
(( LP_ENABLE_TITLE = LP_ENABLE_TITLE && LP_ENABLE_SCREEN_TITLE ))
LP_TITLE_OPEN=$'\Ek'
# "\e\" but on bash \ must be escaped
LP_TITLE_CLOSE=$'\E'"$_LP_BACKSLASH"
else
LP_BRACKET_OPEN="${LP_MARK_BRACKET_OPEN}"
LP_BRACKET_CLOSE="${LP_MARK_BRACKET_CLOSE}"
LP_TITLE_OPEN=$'\E]0;'
LP_TITLE_CLOSE=$'\a'
fi
Expand Down Expand Up @@ -782,6 +778,17 @@ _lp_chroot() {
return 1
}

_lp_multiplexer() {
if [[ "$TERM" == screen* ]]; then
lp_mulitplexer=screen
return 0
elif [[ -n ${TMUX-} ]]; then
lp_mulitplexer=tmux
return 0
fi
return 1
}

# Put the hostname if not locally connected
# color it in cyan within SSH, and a warning red if within telnet
# else display the host without color
Expand Down Expand Up @@ -2192,6 +2199,15 @@ _lp_theme_activate() {
_lp_hostname_color
LP_HOST="$lp_hostname_color"

# If we are running in a terminal multiplexer, brackets are colored
if _lp_multiplexer; then
LP_BRACKET_OPEN="${LP_COLOR_IN_MULTIPLEXER}${LP_MARK_BRACKET_OPEN}${NO_COL}"
LP_BRACKET_CLOSE="${LP_COLOR_IN_MULTIPLEXER}${LP_MARK_BRACKET_CLOSE}${NO_COL}"
else
LP_BRACKET_OPEN="${LP_MARK_BRACKET_OPEN}"
LP_BRACKET_CLOSE="${LP_MARK_BRACKET_CLOSE}"
fi

# Same as bash '\l', but inlined as a constant as the value will not change
# during the shell's life
LP_TTYN="$(basename -- "$(tty)" 2>/dev/null)"
Expand Down

0 comments on commit 0200b99

Please sign in to comment.