diff --git a/news/prompt_superuser.rst b/news/prompt_superuser.rst new file mode 100644 index 000000000..f2ad15b88 --- /dev/null +++ b/news/prompt_superuser.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Show ``root`` and ``@#`` in prompt if user is superuser. + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/xonsh/prompt/base.py b/xonsh/prompt/base.py index 4ff245fcf..90af7e855 100644 --- a/xonsh/prompt/base.py +++ b/xonsh/prompt/base.py @@ -338,9 +338,10 @@ class PromptFields(tp.MutableMapping[str, "FieldType"]): self.update( dict( user=xp.os_environ.get( - "USERNAME" if xp.ON_WINDOWS else "USER", "" + "USERNAME" if xp.ON_WINDOWS else "USER", + "root" if xt.is_superuser() else "", ), - prompt_end="#" if xt.is_superuser() else "@", + prompt_end="@#" if xt.is_superuser() else "@", hostname=socket.gethostname().split(".", 1)[0], cwd=_dynamically_collapsed_pwd, cwd_dir=lambda: os.path.join(os.path.dirname(_replace_home_cwd()), ""),