You can use a zsh prompt expansion sequence
, found in the manual page for zshmisc
.
If you're using oh-my-zsh
it's a bit tricky: you need to figure out what theme you're using, then modify it to include the right prompt sequence. The themes are kept in $HOME/.oh-my-zsh/themes
. If you're really stuck, you could include the theme you're using in your question :)
The prompt expansion you're probably looking for is %n
, which expands to $USERNAME
.