From f34996baa605349fa5398a2f49701e1c50a4d628 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 11 Jan 2013 10:15:12 +0100 Subject: [PATCH] Add an option to hide the logged user LP_USER_ALWAYS=1 will display the user, even if he is the same than the logged one. Defaults to 1 (always display the user), set to 0 if you want to hide the logged user (it will always display different users). --- README.md | 2 ++ liquidprompt | 7 ++++++- liquidpromptrc-dist | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e4481c..cb857fb 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,8 @@ the path path * `LP_HOSTNAME_ALWAYS`, choose between always displaying the hostname or showing it only when connected with a remote shell +* `LP_USER_ALWAYS`, choose between always displaying the user or showing +it only when he is different from the logged one You can also force some features to be disabled, to save some time in the prompt building: diff --git a/liquidprompt b/liquidprompt index 5bfad71..375d20b 100755 --- a/liquidprompt +++ b/liquidprompt @@ -188,6 +188,7 @@ _lp_source_config() LP_PATH_LENGTH=${LP_PATH_LENGTH:-35} LP_PATH_KEEP=${LP_PATH_KEEP:-2} LP_HOSTNAME_ALWAYS=${LP_HOSTNAME_ALWAYS:-0} + LP_USER_ALWAYS=${LP_USER_ALWAYS:-1} LP_PS1=${LP_PS1:-""} LP_PS1_PREFIX=${LP_PS1_PREFIX:-"\[\e]0;\u@\h: \w\a\]"} @@ -302,7 +303,11 @@ _lp_user() if [[ ${USER} != "$(logname 2>/dev/null)" ]]; then user="${LP_COLOR_USER_ALT}${_LP_USER_SYMBOL}${NO_COL}" else - user="${LP_COLOR_USER_LOGGED}${_LP_USER_SYMBOL}${NO_COL}" + if [[ "${LP_USER_ALWAYS}" -ne "0" ]] ; then + user="${LP_COLOR_USER_LOGGED}${_LP_USER_SYMBOL}${NO_COL}" + else + user="" + fi fi else user="${LP_COLOR_USER_ROOT}${_LP_USER_SYMBOL}${NO_COL}" diff --git a/liquidpromptrc-dist b/liquidpromptrc-dist index 51df55c..b3f54e1 100644 --- a/liquidpromptrc-dist +++ b/liquidpromptrc-dist @@ -33,6 +33,11 @@ LP_PATH_KEEP=2 # set to 1 if you want to always see the hostname LP_HOSTNAME_ALWAYS=0 +# Do you want to display the user, even if he is the same than the logged one? +# Defaults to 1 (always display the user) +# set to 0 if you want to hide the logged user (it will always display different users) +LP_USER_ALWAYS=1 + # Do you want to use the permissions feature ? # Recommended value is 1 LP_ENABLE_PERM=1