Andonade
Andonade

Reputation: 1

Encountering an error during configuration of iTerm2

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?

Upvotes: 0

Views: 88

Answers (1)

yut23
yut23

Reputation: 3064

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.

Upvotes: 0

Related Questions