Skip to content

Instantly share code, notes, and snippets.

@Zeuh
Created July 19, 2012 18:29
Show Gist options
  • Select an option

  • Save Zeuh/3145848 to your computer and use it in GitHub Desktop.

Select an option

Save Zeuh/3145848 to your computer and use it in GitHub Desktop.
diff --git a/liquidprompt.bash b/liquidprompt.bash
index cad36bd..9d824d3 100644
--- a/liquidprompt.bash
+++ b/liquidprompt.bash
@@ -87,7 +87,7 @@ __user()
# if user is not root
if [ "$EUID" -ne "0" ] ; then
# if user is not login user
- if [[ ${USER} != $(logname) ]]; then
+ if [[ ${USER} != $(id -nu) ]]; then
user="${LIGHT_GREY}\u${NO_COL}"
else
user="\u"
@nojhan
Copy link
Copy Markdown

nojhan commented Jul 23, 2012

Beware, id does not gives the user that logged in (and that's what we want in this prompt) if you use sudo:

[nojhan:~] $ logname
nojhan
[nojhan:~] $ id -nu
nojhan
[nojhan:~] $ sudo logname
nojhan
[nojhan:~] $ sudo id -nu
root

Commit 754839a normally solves the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment