I'm using zsh with powerlevel9k theme and I would like to know how to remove hostname from my terminal. This is how my terminal looks right now:


I would like to change it to only show kathi instead of kathi@Quantiphi-927.

I don't have the PS1 line in my .zshrc file and adding the PS1 line makes no difference. I tried:

export PS1="\u\W\\$ "


PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  • 2
    Please edit and provide your current PS1, e.g. by adding the respective line from your .zshrc file. – dessert Jul 31 '19 at 20:50
  • Start with common mistakes: Did you remember to reload your .bashrc after editing? – user535733 Jul 31 '19 at 21:36
  • yes i did ttry reloading by both opening a new terminal and using ~source .zshrc – vamshi krishna Aug 1 '19 at 4:45

If you are using Powerlevel10k, simply run p10k configure.

If you are using the original Powerlevel9k (you'll know it if your prompt is slow), type this:

echo 'POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir vcs)` >>! ~/.zshrc
exec zsh

As you are using Powerlevel9k, there is a variable called POWERLEVEL9K_CONTEXT_TEMPLATE that you can change to hide the hostname.

the default option for POWERLEVEL9K_CONTEXT_TEMPLATE is %n@%m, %n for username and %m for the machine.

to hide the hostname:

  1. Open the ~/.zshrc : sudo nano ~/.zshrc

  2. add POWERLEVEL9K_CONTEXT_TEMPLATE="%n" at the end of .zshrc file.

  3. save the file.

you will get a result like below:

enter image description here

for more information please check the powerlevel9k#context documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.