From 5794c3aeac3367abdd7e9ba83f5618253173dc6e Mon Sep 17 00:00:00 2001 From: nojhan Date: Sun, 23 Sep 2012 23:07:51 +0200 Subject: [PATCH] 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). --- README.md | 2 ++ liquid.theme | 1 + liquidprompt | 10 +++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 359eaa6..063ffc1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/liquid.theme b/liquid.theme index 3fefbfc..b434241 100644 --- a/liquid.theme +++ b/liquid.theme @@ -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 diff --git a/liquidprompt b/liquidprompt index f86929e..96b13a2 100755 --- a/liquidprompt +++ b/liquidprompt @@ -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