jimeh/git-aware-prompt

Improvements to the installation documentation

iluwatar opened this issue · 15 comments

I was using Lubuntu 14.04 and according to the documentation I should

Edit your ~/.bash_profile or ~/.profile and add the following to the top:

However, this does not work. I needed to edit my .bashrc file to make it work. Also, the documentation does not mention that after cloning the repository you should make the scripts executable with chmod command.

I agree with you. The same happened to me about .bashrc on Ubuntu 14.04.
Also I'm not sure but export doesn't seems to be permanent.
El 12/08/2015 00:21, "Ilkka Seppälä" notifications@github.com escribió:

I was using Lubuntu 14.04 and according to the documentation I should

Edit your ~/.bash_profile or ~/.profile and add the following to the top:

However, this does not work. I needed to edit my .bashrc file to make it
work. Also, the documentation does not mention that after cloning the
repository you should make the scripts executable with chmod command.


Reply to this email directly or view it on GitHub
#24.

jimeh commented

@iluwatar Sorry for the confusion, I'll have a closer look at Ubuntu's shell init setup and update the readme as needed. I'm not sure why you'd need to make the files executable though, as they're just loaded by bash, and never directly executed.

@srvanrell What kind of issues have you had with the export statement? Seems a bit strange that it wouldn't work, so I'm quite curious :)

.bash_profile is typically run only in login shells, and .bashrc in other shells - depending on your terminal emulator (or distro?), new windows/tabs may or may not start login shells, and shell instances invoked with bash (i.e. from another shell) should be non-login shells and run .bashrc.

jimeh commented

@lethosor That makes sense. I've been handicapped by OSX always loading the .profile when starting a new shell, regardless of if it's a new window/tab/app/whatever... lol

@jimeh export works properly. Always. I meant that when I open a new terminal (without rebooting) the earlier export execution (in another terminal) don't take effect. May be that's the expected way. I'm not familiar with export so could be that I'm wrong.

Let me restart the question. How many times and where should the export command be executed to get git-aware-prompt always working?

export only works on a per-shell basis. If you want to make git-aware-prompt work when .bashrc is run but not .bash_profile, you can add your configuration to .bashrc as well, add source ~/.bash_profile to .bashrc (which will (re-)run everything in .bash_profile, of course, including any $PATH settings you might have), or create a separate shell script with your git-aware-prompt settings and run it from .bash_profile and .bashrc.

@lethosor thanks for your clarification! I've added to bashrc but it was
just trial and error. It's good to know the right way.

export only works on a per-shell basis. If you want to make
git-aware-prompt work when .bashrc is run but not .bash_profile, you can
add your configuration to .bashrc as well, source ~/.bash_profile to
.bashrc (which will (re-)run everything in .bash_profile, of course,
including any $PATH settings you might have), or create a separate shell
script with your git-aware-prompt settings and run it from .bash_profile
and .bashrc.


Reply to this email directly or view it on GitHub
#24 (comment)
.

I was able to get this working on my Mac by putting everything inside .bashrc. Also, thanks to @iluwatar for pointing out making the scripts executable after cloning the repo.

You shouldn't have to make them executable if you're sourcing them, though - are you running the scripts directly?

@lethosor You are correct. I removed the executable permission and all continues to work as expected.

On Debian .profile lines specified works but they must be at the bottom of the file, not at the top. At least this work for me.

jimeh commented

It seems like what actually works varies quite a bit between OS/distro. I'll try to expand on the installation instructions so they're a bit more informative and helpful than a single sentence.

I can confirm for Ubuntu 15.10 that we need to use the instructions on .bashrc instead of .profile.

Hi!
I also can confirm that I need to put it on .bashrc on Ubuntu 14.04.1 to get it working. I am using Terminator.

Can you please update the README?

Just opened a PR #31 for this.