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).
This commit is contained in:
Johann Dreo 2013-01-11 10:15:12 +01:00
parent 9b4f27a938
commit f34996baa6
3 changed files with 13 additions and 1 deletions

View File

@ -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:

View File

@ -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}"

View File

@ -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