0

This error happens in my ~/.zshrc when configuring iTerm2.

.zshrc:117: parse error near `\n'

The following is the last few lines of my ~/.zshrc.

111 source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
112 #if brew list | grep coreutils > /dev/null ; then PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH" alias ls='ls -F --show-control-chars --color=auto' eval `gdircolors -b $HOME/.dir_colors` fi
113
114 # to customize the prompt, run `p10k configure` or edit ~/.p10k.zsh.
115 [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
116 POWERLEVEL9K_DISABLE_CONFIGURATION=true

When I turn the line 112 into comment, the error then disappear.

How can I fix this without turning it into comment?

0

1 Answer 1

0

You need to separate the commands on that line, either by adding semicolons or by breaking it into multiple lines. I recommend the latter, as it's much more readable:

if brew list | grep coreutils > /dev/null ; then
  PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"
  alias ls='ls -F --show-control-chars --color=auto'
  eval `gdircolors -b $HOME/.dir_colors`
fi

That specific parse error is from the if never finding a matching fi command, since it was parsed as an argument to alias instead.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! The problem has been solved through your method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.