Add username and host name to zsh prompt ? backup the prompt

Q1.
If i am right, to back up this zsh prompt, i only need to backup “.p10k.zsh” file.

Q2.
I want to add usrname and host machine name onto zsh prompt on the most right side.
But to me It is so complicated .

My current prompt


╭─ ~/sshfs-mount                                                                       ✔ │ 21:51:19 
╰─               



I read several time of this session, but simply have no idea what the instruction is.

Url:

### How do I add username and/or hostname to prompt?

When using Lean, Classic or Rainbow style, prompt shows `username@hostname` when you are logged in as root or via SSH. There is little value in showing `username` or `hostname` when you are logged in to your local machine as a normal user. So the absence of `username@hostname` in your prompt is an indication that you are working locally and that you aren't root. You can change it, however.

Open `~/.p10k.zsh`. Close to the top you can see the most important parameters that define which segments are shown in your prompt. All generally useful prompt segments are listed in there. Some of them are enabled, others are commented out. One of them is of interest to you.

typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
... 
context # user@hostname 
... 
)

Search for `context` to find the section in the config that lists parameters specific to this prompt segment. You should see the following lines:

# Don't show context unless running with privileges or in SSH. # Tip: Remove the next line to always show context. typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION=

If you follow the tip and remove (or comment out) the last line, you'll always see `username@hostname` in prompt. You can change the format to just `username`, or change the color, by adjusting the values of parameters nearby. There are plenty of comments to help you navigate.

You can also move `context` to a different position in `POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS` or even to `POWERLEVEL9K_LEFT_PROMPT_ELEMENTS`.

i have located this line, but it is NOT commented out by default, so what should i do with it to make it works ?

... 
context # user@hostname 
...
)

Remove the last line ? which last line ?

If you follow the tip and remove (or comment out) the last line, you'll always see `username@hostname` in prompt. 

Remove the “next line” ? is this the “next line” ?

Tip: Remove the next line to always show context. typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION=

p10.zsh

The list of segments shown on the left. Fill it with the most important segments.

typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
# =========================[ Line #1 ]=========================
os_icon # os identifier
host # your hostname
time
dir # current directory
vcs # git status
# =========================[ Line #2 ]=========================
newline # \n
user # username
prompt_char # prompt symbol
)