display an arrow if http_proxy is in use

This commit is contained in:
nojhan 2012-08-09 12:11:51 +02:00
parent f851d6cf4f
commit 3ba404d106
2 changed files with 13 additions and 2 deletions

View File

@ -45,6 +45,7 @@ different colors for each case;
a red one if he has not; a red one if he has not;
* the current directory in bold, shortened if it takes too much space, while * the current directory in bold, shortened if it takes too much space, while
preserving the first two directories; preserving the first two directories;
* an up arrow if an HTTP proxy is in use;
* the name of the current branch if you are in a version control repository * the name of the current branch if you are in a version control repository
(git, mercurial or subversion), in green if everything is up to date, in red if (git, mercurial or subversion), in green if everything is up to date, in red if
there is changes, in yellow if there is pending commits to push; there is changes, in yellow if there is pending commits to push;
@ -95,4 +96,5 @@ what you want to see by editing the PS1 variable here.
* Does not display the number of commits to be pushed in Mercurial repositories. * Does not display the number of commits to be pushed in Mercurial repositories.
* Subversion repository cannot display commits to be pushed, this is a * Subversion repository cannot display commits to be pushed, this is a
limitation of the Subversion versionning model. limitation of the Subversion versionning model.
* The proxy detection only uses the `$http_proxy` environment variable.

View File

@ -294,6 +294,14 @@ __host_color()
echo -ne "${ret}${NO_COL}" echo -ne "${ret}${NO_COL}"
} }
# put an arrow if an http proxy is set
__proxy()
{
if [[ ! -z "$http_proxy" ]] ; then
echo -ne "↥"
fi
}
# BASH function that shortens # BASH function that shortens
# a very long path for display by removing # a very long path for display by removing
# the left most parts and replacing them # the left most parts and replacing them
@ -730,6 +738,7 @@ __set_bash_prompt()
__HOST=$(__host_color) __HOST=$(__host_color)
__PERM=$(__permissions_color) __PERM=$(__permissions_color)
__PWD=$(__shorten_path "$PWD" $LP_PATH_LENGTH) __PWD=$(__shorten_path "$PWD" $LP_PATH_LENGTH)
__PROXY=$(__proxy)
# right of main prompt: space at left # right of main prompt: space at left
__GIT=$(__sl "$(__git_branch_color)") __GIT=$(__sl "$(__git_branch_color)")
@ -748,12 +757,12 @@ __set_bash_prompt()
if [[ "$EUID" -ne "0" ]] if [[ "$EUID" -ne "0" ]]
then then
# path in foreground color # path in foreground color
PS1="${PS1}${BOLD_FG}${__PWD}${NO_COL}]" PS1="${PS1}${BOLD_FG}${__PWD}${NO_COL}]${__PROXY}"
# add VCS infos # add VCS infos
PS1="${PS1}${__GIT}${__HG}${__SVN}" PS1="${PS1}${__GIT}${__HG}${__SVN}"
else else
# path in yellow # path in yellow
PS1="${PS1}${YELLOW}${__PWD}${NO_COL}]" PS1="${PS1}${YELLOW}${__PWD}${NO_COL}]${__PROXY}"
# do not add VCS infos # do not add VCS infos
fi fi
# add return code and prompt mark # add return code and prompt mark