Skip to content

Commit

Permalink
Add _lp_http_proxy()
Browse files Browse the repository at this point in the history
The original check only looked for $http_proxy, which is only one var
that can contain proxy info. I don't know how often users use this, but
I really think it should cover more ground.
  • Loading branch information
Rycieos committed Nov 25, 2020
1 parent 1a56d58 commit 78dee3c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions liquidprompt
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,22 @@ _lp_multiplexer() {
return 1
}

_lp_http_proxy() {
(( LP_ENABLE_PROXY )) || return 2

if [[ -n "${http_proxy-}${HTTP_PROXY-}${https_proxy-}${HTTPS_PROXY-}${all_proxy-}${ALL_PROXY-}" ]]; then
lp_http_proxy="${http_proxy:-${HTTP_PROXY:-${https_proxy:-${HTTPS_PROXY:-${all_proxy:-$ALL_PROXY}}}}}"
else
return 1
fi
}

_lp_http_proxy_color() {
_lp_http_proxy || return $?

lp_http_proxy_color="${LP_COLOR_PROXY}${LP_MARK_PROXY}${NO_COL}"
}

# return: 0 if login user, 1 if not, 2 if root
_lp_user() {
if (( EUID == 0 )); then
Expand Down Expand Up @@ -2298,8 +2314,8 @@ _lp_theme_prompt() {
fi

# in main prompt: no space
if [[ "$LP_ENABLE_PROXY,${http_proxy-}" = 1,?* ]]; then
LP_PROXY="$LP_COLOR_PROXY$LP_MARK_PROXY$NO_COL"
if _lp_http_proxy_color; then
LP_PROXY="$lp_http_proxy_color"
else
LP_PROXY=
fi
Expand Down

0 comments on commit 78dee3c

Please sign in to comment.