Feature: blue @ when connected with X11 support

If the current connection supports X (if we are in a X session or if we have
enabled X11 forwarding under ssh), the @ displayed in front of the hostname
is colored in blue (use LP_COLOR_X11 to change the color).
This commit is contained in:
nojhan 2012-09-23 23:07:51 +02:00
parent 6db36ab573
commit 5794c3aeac
3 changed files with 12 additions and 1 deletions

View File

@ -46,6 +46,7 @@ and bring it back with `fg`), if there is any;
any;
* the current user, in bold yellow if it is root, in light white if it is not
the same as the login user;
* a blue @ if the connection has X11 support;
* the current host, if you are connected via an SSH or telnet connection, with
different colors for each case;
* a green colon if the user has write permissions on the current directory,
@ -200,6 +201,7 @@ Set to a null string "" if you do not want color.
* `LP_COLOR_HOST` local host
* `LP_COLOR_SSH` connected via SSH
* `LP_COLOR_TELNET` connected via telnet
* `LP_COLOR_X11` connected with X11 support
* Separation mark (aka permiison in the working dir)
* `LP_COLOR_WRITE` have write permission
* `LP_COLOR_NOWRITE` do not have write permission

View File

@ -65,6 +65,7 @@ LP_COLOR_USER_ROOT="$BOLD_YELLOW" # root
LP_COLOR_HOST="" # local host
LP_COLOR_SSH="$BOLD_CYAN" # connected via SSH
LP_COLOR_TELNET="$WARN_RED" # connected via telnet
LP_COLOR_X11="$BLUE" # connected with X11 support
# Separation mark (aka permiison in the working dir)
LP_COLOR_WRITE="$GREEN" # have write permission

View File

@ -225,6 +225,7 @@ _lp_source_config()
LP_COLOR_HOST=${LP_COLOR_HOST:-""}
LP_COLOR_SSH=${LP_COLOR_SSH:-$BOLD_CYAN}
LP_COLOR_TELNET=${LP_COLOR_TELNET:-$WARN_RED}
LP_COLOR_X11=${LP_COLOR_X11:-$BLUE}
LP_COLOR_WRITE=${LP_COLOR_WRITE:-$GREEN}
LP_COLOR_NOWRITE=${LP_COLOR_NOWRITE:-$RED}
LP_COLOR_UP=${LP_COLOR_UP:-$GREEN}
@ -331,13 +332,20 @@ _lp_connection()
# else diplay the host without color
# The connection is not expected to change from inside the shell, so we
# build this just once
LP_HOST="${NO_COL}@"
LP_HOST=""
if [[ -r /etc/debian_chroot ]] ; then
local debchroot
debchroot=$(cat /etc/debian_chroot)
LP_HOST="${LP_HOST}(${debchroot})"
fi
# If we are connected with a X11 support
if [[ -n "$DISPLAY" ]] ; then
LP_HOST="${LP_COLOR_X11}${LP_HOST}@${NO_COL}"
else
LP_HOST="${LP_HOST}@"
fi
case "$(_lp_connection)" in
lcl)
if [[ "$LP_HOSTNAME_ALWAYS" != 1 ]] ; then