spaceship-prompt: parse error near `&&'

Issue

Got error message when login to console

/home/vagrant/.oh-my-zsh/custom/themes/spaceship.zsh-theme:329: parse error near `&&'

Screenshot

default

Environment

Operating system: Linux Ubuntu 14.04 VM Terminal emulator: Xshell 5 ZSH version: 5.05

Relevant .zshrc

ZSH_THEME="spaceship"

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 18 (7 by maintainers)

Most upvoted comments

It seems there is no official backport for ZSH newer version for Ubuntu 14.04.

I upgraded Ubuntu from 14 to 16 (on WSL) and thus upgraded ZSH to 5.1 so now the issue is gone

Same issue on Bash for Windows (Ubuntu 14.04.5) ZSH 5.0.5

Thanks @nfischer I solve this upgrading my zsh.

Mac has a native zsh 5.0.5 and brew install 5.4.2 BUT not always change the 5.4.2 as a default zsh. You need to override this behavior to works fine!

If you have Homebrew installed, you can do this.

check the zsh info

brew info zsh

install zsh

brew install --without-etcdir zsh

add shell path

sudo vim /etc/shells

add the following line into the very end of the file(/etc/shells)

/usr/local/bin/zsh

change default shell

chsh -s /usr/local/bin/zsh

On 5.0.5, I see problems with these lines:

https://github.com/denysdovhan/spaceship-zsh-theme/blob/68068b61e5e8852dcdfff1f19a796758f86d2cde/spaceship.zsh#L337

and

https://github.com/denysdovhan/spaceship-zsh-theme/blob/68068b61e5e8852dcdfff1f19a796758f86d2cde/spaceship.zsh#L803

Both of these lines can be resolved by replacing [[ $foo ]] with [[ -n $foo ]]. I’m pretty sure this is a dupe of zsh-users/zsh-syntax-highlighting#225 (it uses the solution I’ve described). #121 had the same root cause too.

It sounds like this only appears for old versions of zsh (the borderline is somewhere between 5.0.5 and 5.1)


We can add the fix I mentioned, but spaceship still won’t work properly on 5.0.5 (until #190 is resolved)

Thanks for that, I found the issue:

+/home/thompsons/.oh-my-zsh/oh-my-zsh.sh:9> fpath=( /home/thompsons/.oh-my-zsh/functions /home/thompsons/.oh-my-zsh/completions /home/thompsons/.oh-my-zsh/plugins/git /home/thompsons/.oh-my-zsh/functions /home/thompsons/.oh-my-zsh/completions /usr/share/zsh/site-functions /usr/share/zsh/4.3.11/functions )

My zsh installed in a different location, and is 5.4.2, but the zsh that’s called by oh-my-zsh is the default that came with my distro, which is 4.3.11 (which obviously isn’t supported).

edit: That directory doesn’t even exist…