Search code examples
macositerm2

How to change username on iterm2


I would like to change the username showned on iterm2. Now is looking something like this -> macbook@... I would like to change macbook with my name using a command, is that possible?


Solution

  • First, as a safety precaution, check and save your current terminal prompt. You can get it with the following command:

    echo $PROMPT

    Save it, so you can restore the original prompt if needed.

    Now, confirm that you are using zsh shell, this can be done by using the command echo $0, it should return -zsh. Zsh is the default macOS shell.

    Next need to edit ~/.zshrc. If you changed the default shell before, this solution won't work.

    At the end of the file you can add your own custom prompt like so:

    PROMPT="<prompt string goes here>"

    The prompt strings can be quite tricky to write manually, so your best bet would be looking up zsh prompt generator on google and using that as an example. Once your file is ready and saved, use source ~/.zshrc to apply the changes.