0

I'm trying to figure out why zsh's prompt looks like this:

zsh prompt example

(in text form):

\[\]\u\[\] at \[\]\h\[\] in \[\]\w\[\]$(__git_ps1) \[\]$(git_diff)\n\[\]($(date +'1:MikesMBP.local ')) \[\]$\[\]

I'd like it to list my pwd and username normally like it does in bash before calling zsh. Here's my .zshrc:

# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt appendhistory autocd beep extendedglob nomatch notify
bindkey -v
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/Users/mike/.zshrc'

autoload -Uz compinit
compinit
# End of lines added by compinstall

This is just a standard config created when first starting zsh. I've tried both the built-in OS X zsh and homebrew's zsh and they produce the same error. Do you see something that would cause this?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

2 Answers2

5

You exported the variable PS1 in the previous shell so zsh inherits it and uses the variable to display your prompt. This is the reason why you should not export shell parameters like PS*, had PS1 not be exported zsh would've used its default prompt until you changed PS1 in your .zshrc or used the prompt system.

llua
  • 6,900
2

bash uses \[ and \] to mark parts of the prompt which are nonprinting.

zsh uses %{ and %} for the same purpose.

The xterm manual has a section which mentions this.

Thomas Dickey
  • 76,765