When I execute source ~/.bash_profile I get this error:

line 14 syntax error: unexpected end of file

I tried to delete the last line to no avail.

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc

if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash

if [ "$PS1" ]; then PS1="[\e[0;36m]\W\n[\e[m][\e[1;31m]\$[\e[m]" fi
function gi() { curl -L -s https://www.gitignore.io/api/$@ ;}
export LSCOLORS=cxfxcxdxbxegedabagacad
  • 1
    Why to test PS1 if you have just set it ? It's always true. source and . command are same.
    – kshji
    Feb 5 '16 at 17:35
  • 1
    [ "$PS1" ] && echo "PS1 value is $PS1"
    – kshji
    Feb 5 '16 at 17:44

There's a missing semicolon:

if [ "$PS1" ]; then PS1="[\e[0;36m]\W\n[\e[m][\e[1;31m]\$[\e[m]" fi 

should be

if [ "$PS1" ]; then PS1="[\e[0;36m]\W\n[\e[m][\e[1;31m]\$[\e[m]"; fi

Or, format it the same way as your other if statements above this one.

  • I did that and removed the last list as well. but now I am not getting the prompt when starting the terminal. Just the first line (Last login: somedate ttys002)
    – Fred J.
    Feb 5 '16 at 0:04
  • A couple of things. For me, The only thing in my .bash_profile is ". ~/.bashrc". .bashrc contains PS1 setting, and everything else. I don't test for PS1, I just set it. Also, you need to put backslashes before each bracket surrounding your escape codes in PS1. For your prompt to work the way you want, it should be PS1='\[\e[36m\]\W\n\[\e[1;31m\]\$\[\e[0m\]'. Hope that helps - matt
    – mtklr
    Feb 5 '16 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.