missing end to balance this if statement

Arthur picture Arthur · Sep 14, 2016 · Viewed 8k times · Source

i try to add this lines to my .bash-profile

if [ -f "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh" ];then
 source "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh"
fi

but I get this error

Missing end to balance this if statement
.bash_profile (line 2): if [ -f "$(brew --prefix)/opt/bash-git-       prompt/share/gitprompt.sh" ]; then
                    ^
from sourcing file .bash_profile
called on standard input

Dose anyone have an idea why? I have the code from here https://github.com/magicmonty/bash-git-prompt

Answer

chepner picture chepner · Sep 14, 2016

Although the linked repository contains a script for fish, the README does not provide any directions for how to use that script. Not having used fish in several years, I think what you want to do is add

if status --is-login
  source (brew --prefix)"/opt/bash-git-prompt/share/gitprompt.fish"
end

to ~/.config/fish/config.fish instead. The if status command prevents the file from being unnecessarily sourced if you aren't starting an interactive shell.