JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.02k stars 2.37k forks source link

Ubuntu20.04 UserName not changed #2850

Closed Walter-Gu closed 2 years ago

Walter-Gu commented 2 years ago

Code of Conduct

What happened?

ubuntu login user "Jane"

"template": "{{ .UserName }}@{{ .HostName }} ",

.UserName display Jane

when "sudo su root " .UserName display Jane

Username is always Jane, cannot display root

Theme

{ "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", "blocks": [ { "alignment": "left", "segments": [ { "background": "#222222", "foreground": "#666666", "leading_diamond": "\ue0b6", "style": "diamond", "template": "{{ .UserName }}@{{ .HostName }} ", "type": "session" }, { "background": "#0087D8", "foreground": "#003544", "powerline_symbol": "\ue0b0", "properties": { "folder_separator_icon": "/", "style": "full" }, "style": "powerline", "template": " {{ .Path }} ", "type": "path" }, { "background": "#d2ff5e", "background_templates": [ "{{ if or (.Working.Changed) (.Staging.Changed) }}#ff9248{{ end }}", "{{ if and (gt .Ahead 0) (gt .Behind 0) }}#f26d50{{ end }}", "{{ if gt .Ahead 0 }}#89d1dc{{ end }}", "{{ if gt .Behind 0 }}#f17c37{{ end }}" ], "foreground": "#193549", "powerline_symbol": "\ue0b0", "properties": { "branch_icon": "", "fetch_stash_count": true, "fetch_status": true, "fetch_upstream_icon": true }, "style": "powerline", "template": " {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} {{ .StashCount }}{{ end }} ", "type": "git" }, { "background": "#003543", "foreground": "#fff", "powerline_symbol": "\ue0b0", "style": "powerline", "template": "<#fff> </>{{ .CurrentDate | date .Format }} ", "type": "time" }, { "background": "#83769c", "foreground": "#ffffff", "properties": { "always_enabled": true }, "style": "diamond", "template": " {{ .FormattedMs }}", "trailing_diamond": "\ue0b4", "type": "executiontime" } ], "type": "prompt" }, { "alignment": "left", "newline": true, "segments": [ { "foreground": "#f5b403", "style": "plain", "template": " >>> ", "type": "root" }, { "foreground": "#f1184c", "style": "plain", "template": "", "type": "text" } ], "type": "prompt" } ], "console_title_template": "{{.UserName}}@{{.HostName}} in {{ .PWD }}", "final_space": true, "version": 2 }

What OS are you seeing the problem on?

Linux

Which shell are you using?

bash

Log output

Version: 11.1.0

Segments:

ConsoleTitle(true)   -  23 ms - Jane@linux-Jane in ~/.poshthemes
session(true)        -   1 ms - Jane@linux-Jane 
path(true)           -   0 ms -  ~/.poshthemes 
git(false)           -   2 ms - 
time(true)           -   1 ms -  11:38:31 
executiontime(true)  -   0 ms -  0ms
root(true)           -   0 ms -  >>> 
text(false)          -   0 ms - 

Run duration: 38.206225ms

Cache path: /root/.cache/oh-my-posh

Config path: /root/.poshthemes/unicorn.omp.json

Logs:

2022/09/29 11:38:31 debug: Getenv

2022/09/29 11:38:31 Getenv duration: 20.127µs, args: XDG_CACHE_HOME
2022/09/29 11:38:31 CachePath duration: 62.765µs, args: 
2022/09/29 11:38:31 debug: Getenv
/root/.poshthemes/unicorn.omp.json
2022/09/29 11:38:31 Getenv duration: 14.199µs, args: POSH_THEME
2022/09/29 11:38:31 resolveConfigPath duration: 22.765µs, args: 
2022/09/29 11:38:31 Init duration: 6.836608ms, args: 
2022/09/29 11:38:31 Flags duration: 109ns, args: 
2022/09/29 11:38:31 config.loadConfig duration: 807.623µs, args: 
2022/09/29 11:38:31 Flags duration: 87ns, args: 
2022/09/29 11:38:31 debug: Getenv

2022/09/29 11:38:31 Getenv duration: 2.743µs, args: OMP_CACHE_DISABLED
2022/09/29 11:38:31 Root duration: 1.402µs, args: 
2022/09/29 11:38:31 debug: Shell
process name: bash
2022/09/29 11:38:31 Shell duration: 22.532831ms, args: 
2022/09/29 11:38:31 ErrorCode duration: 154ns, args: 
2022/09/29 11:38:31 debug: Getenv

2022/09/29 11:38:31 Getenv duration: 3.529µs, args: WSL_DISTRO_NAME
2022/09/29 11:38:31 IsWsl duration: 9.957µs, args: 
2022/09/29 11:38:31 debug: Pwd
/root/.poshthemes
2022/09/29 11:38:31 Pwd duration: 36.964µs, args: 
2022/09/29 11:38:31 GOOS duration: 195ns, args: 
2022/09/29 11:38:31 GOOS duration: 102ns, args: 
2022/09/29 11:38:31 GOOS duration: 143ns, args: 
2022/09/29 11:38:31 GOOS duration: 84ns, args: 
2022/09/29 11:38:31 GOOS duration: 90ns, args: 
2022/09/29 11:38:31 GOOS duration: 87ns, args: 
2022/09/29 11:38:31 GOOS duration: 84ns, args: 
2022/09/29 11:38:31 GOOS duration: 82ns, args: 
2022/09/29 11:38:31 GOOS duration: 85ns, args: 
2022/09/29 11:38:31 GOOS duration: 85ns, args: 
2022/09/29 11:38:31 GOOS duration: 80ns, args: 
2022/09/29 11:38:31 GOOS duration: 84ns, args: 
2022/09/29 11:38:31 debug: User
Jane
2022/09/29 11:38:31 User duration: 2.927µs, args: 
2022/09/29 11:38:31 debug: Host
linux-Jane
2022/09/29 11:38:31 Host duration: 5.694µs, args: 
2022/09/29 11:38:31 GOOS duration: 87ns, args: 
2022/09/29 11:38:31 TemplateCache duration: 22.760094ms, args: 
2022/09/29 11:38:31 Flags duration: 156ns, args: 
2022/09/29 11:38:31 debug: Pwd
/root/.poshthemes
2022/09/29 11:38:31 Pwd duration: 2.438µs, args: 
2022/09/29 11:38:31 GOOS duration: 97ns, args: 
2022/09/29 11:38:31 debug: Getenv

2022/09/29 11:38:31 Getenv duration: 2.767µs, args: SSH_CONNECTION
2022/09/29 11:38:31 debug: Getenv

2022/09/29 11:38:31 Getenv duration: 2.307µs, args: SSH_CLIENT
2022/09/29 11:38:31 TemplateCache duration: 161ns, args: 
2022/09/29 11:38:31 TemplateCache duration: 242ns, args: 
2022/09/29 11:38:31 Shell duration: 212ns, args: 
2022/09/29 11:38:31 debug: Pwd
/root/.poshthemes
2022/09/29 11:38:31 Pwd duration: 3.981µs, args: 
2022/09/29 11:38:31 GOOS duration: 187ns, args: 
2022/09/29 11:38:31 debug: Pwd
/root/.poshthemes
2022/09/29 11:38:31 Pwd duration: 2.023µs, args: 
2022/09/29 11:38:31 Flags duration: 90ns, args: 
2022/09/29 11:38:31 debug: Pwd
/root/.poshthemes
2022/09/29 11:38:31 Pwd duration: 1.886µs, args: 
2022/09/29 11:38:31 GOOS duration: 89ns, args: 
2022/09/29 11:38:31 PathSeparator duration: 147ns, args: 
2022/09/29 11:38:31 PathSeparator duration: 105ns, args: 
2022/09/29 11:38:31 PathSeparator duration: 89ns, args: 
2022/09/29 11:38:31 PathSeparator duration: 84ns, args: 
2022/09/29 11:38:31 GOOS duration: 99ns, args: 
2022/09/29 11:38:31 debug: Getenv

2022/09/29 11:38:31 Getenv duration: 2.718µs, args: WSL_DISTRO_NAME
2022/09/29 11:38:31 IsWsl duration: 7.249µs, args: 
2022/09/29 11:38:31 StackCount duration: 161ns, args: 
2022/09/29 11:38:31 DirIsWritable duration: 13.191µs, args: 
2022/09/29 11:38:31 TemplateCache duration: 166ns, args: 
2022/09/29 11:38:31 TemplateCache duration: 211ns, args: 
2022/09/29 11:38:31 Shell duration: 146ns, args: 
2022/09/29 11:38:31 debug: Pwd
/root/.poshthemes
2022/09/29 11:38:31 Pwd duration: 3.052µs, args: 
2022/09/29 11:38:31 GOOS duration: 189ns, args: 
2022/09/29 11:38:31 debug: Getenv

2022/09/29 11:38:31 Getenv duration: 2.83µs, args: WSL_DISTRO_NAME
2022/09/29 11:38:31 IsWsl duration: 7.202µs, args: 
2022/09/29 11:38:31 GOOS duration: 126ns, args: 
2022/09/29 11:38:31 debug: CommandPath
/usr/bin/git
2022/09/29 11:38:31 CommandPath duration: 1.465861ms, args: git
2022/09/29 11:38:31 HasCommand duration: 1.479244ms, args: git
2022/09/29 11:38:31 debug: Pwd
/root/.poshthemes
2022/09/29 11:38:31 Pwd duration: 2.547µs, args: 
2022/09/29 11:38:31 error: HasParentFilePath
stat /.git: no such file or directory
2022/09/29 11:38:31 HasParentFilePath duration: 27.571µs, args: .git
2022/09/29 11:38:31 debug: Pwd
/root/.poshthemes
2022/09/29 11:38:31 Pwd duration: 2.801µs, args: 
2022/09/29 11:38:31 GOOS duration: 195ns, args: 
2022/09/29 11:38:31 TemplateCache duration: 271ns, args: 
2022/09/29 11:38:31 TemplateCache duration: 360ns, args: 
2022/09/29 11:38:31 Shell duration: 297ns, args: 
2022/09/29 11:38:31 debug: Pwd
/root/.poshthemes
2022/09/29 11:38:31 Pwd duration: 3.266µs, args: 
2022/09/29 11:38:31 GOOS duration: 166ns, args: 
2022/09/29 11:38:31 ExecutionTime duration: 221ns, args: 
2022/09/29 11:38:31 TemplateCache duration: 206ns, args: 
2022/09/29 11:38:31 TemplateCache duration: 273ns, args: 
2022/09/29 11:38:31 Shell duration: 119ns, args: 
2022/09/29 11:38:31 Flags duration: 149ns, args: 
2022/09/29 11:38:31 debug: Pwd
/root/.poshthemes
2022/09/29 11:38:31 Pwd duration: 2.749µs, args: 
2022/09/29 11:38:31 GOOS duration: 134ns, args: 
2022/09/29 11:38:31 Root duration: 1.834µs, args: 
2022/09/29 11:38:31 TemplateCache duration: 122ns, args: 
2022/09/29 11:38:31 TemplateCache duration: 195ns, args: 
2022/09/29 11:38:31 Shell duration: 90ns, args: 
2022/09/29 11:38:31 debug: Pwd
/root/.poshthemes
2022/09/29 11:38:31 Pwd duration: 2.802µs, args: 
2022/09/29 11:38:31 GOOS duration: 92ns, args: 
2022/09/29 11:38:31 TemplateCache duration: 84ns, args: 
2022/09/29 11:38:31 TemplateCache duration: 232ns, args: 
2022/09/29 11:38:31 Shell duration: 77ns, args: 
2022/09/29 11:38:31 debug: Getenv

2022/09/29 11:38:31 Getenv duration: 3.155µs, args: XDG_CACHE_HOME
2022/09/29 11:38:31 CachePath duration: 31.67µs, args: 
2022/09/29 11:38:31 Flags duration: 84ns, args:
JanDeDobbeleer commented 2 years ago

@TimeVfx according to your shell you're still Jane:

2022/09/29 11:38:31 debug: User
Jane
2022/09/29 11:38:31 User duration: 2.927µs, args:

This comes from the USER environment variable which this command should update in that case. If not, the bug is elsewhere on your system.

Walter-Gu commented 2 years ago

Thanks! Cannot use "su root "when Jane logs in, should be used "su - root" "-" make the shell a login shell

github-actions[bot] commented 9 months ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.