2fce9a4d44f822c03ce874268338961d0761f1a9

Author
Marc Cornellà <marc.cornella@live.com>
Committer
GitHub <noreply@github.com>
Date

Message

agnoster: use %n instead of $USER to fix quoting

Fixes #7268

With `$USER`, we'd need to quote it in case special characters like `\` are present in
the $USER value, like if the user is part of an AD domain.

With `%n` the quoting is done automatically by zsh.
See http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information

Diff

 1diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
 2index 1ac3fc96b32c96cbe355adebb4b0c43c6d2d59f7..0edb773aac7183a17c64df154e3db9440c303155 100644
 3--- a/themes/agnoster.zsh-theme
 4+++ b/themes/agnoster.zsh-theme
 5@@ -89,7 +89,7 @@ prompt_end() {
 6 # Context: user@hostname (who am I and where am I)
 7 prompt_context() {
 8   if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
 9-    prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
10+    prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
11   fi
12 }
13