Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call from .bashrc instead of .bash_profile? #43

Open
jpmv27 opened this issue Aug 16, 2016 · 6 comments
Open

Call from .bashrc instead of .bash_profile? #43

jpmv27 opened this issue Aug 16, 2016 · 6 comments

Comments

@jpmv27
Copy link

jpmv27 commented Aug 16, 2016

The instructions say to install in .bash_profile. If you do this, then find_git_branch and find_git_dirty functions aren't defined in any bash/xterm started from a login shell, so git_branch and git_dirty variables don't get updated.

I think the instructions should be changed to recommend installation in .bashrc instead

@lethosor
Copy link
Contributor

lethosor commented Aug 16, 2016

This depends on whether your terminal emulator starts login shells (which load .bash_profile) or non-login shells (which load .bashrc) by default. Both .bash_profile and .bashrc are already mentioned in the readme.

See also #24, #31

@jpmv27
Copy link
Author

jpmv27 commented Aug 16, 2016

True, and I have been using git-aware-prompt for a while without noticing the problem because I was always ssh'ing to a Linux VM, so every shell was a login shell.
But I tripped over this when I started using it on a box where I am logged into KDE and then running Konsole, which is not run as a login shell. Then it doesn't work any more.
Anyway, .bash_profile should source .bashrc, so running git-aware-prompt should always work if placed in .bashrc, may not always work if placed in .bash_profile. I'm suggesting it would be "better" to suggest .bashrc as the first choice.

@lethosor
Copy link
Contributor

While it is a good idea to source .bashrc from .bash_profile, or link one to the other, I doubt that everyone who uses git-aware-prompt has done that, given previously-reported issues. Switching the order in the readme is bound to lead to more confusion and issues like "Change .bashrc to .bash_profile?".

I think the best solution is to mention that different environments may read from different files when starting a shell, so people either need to figure out which one to add git-aware-prompt to or ensure that it is set up regardless of which file is loaded (e.g. sourcing one file from the other, linking one file to the other, etc.).

@jpmv27
Copy link
Author

jpmv27 commented Aug 16, 2016

What you propose is a good compromise.
It seems that in all the environments I'm currently using (Ubuntu 12.04 and later, Fedora 23 and later) that .bash_profile sources .bashrc, but I don't really know how widespread that is. I do recall that in the (distant) past, that was something that I had to configure myself.
Thanks

@lethosor
Copy link
Contributor

On a fresh installation of Ubuntu 16.04, ~/.bash_profile does not exist, but ~/.profile does (and sources .bashrc when run by bash):

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
...

Neither of these exist on OS X, however, and it probably varies on other Linux distros.

I'll look at updating the readme if I get a chance, although this project hasn't been especially active lately, so I don't know when it'll get merged.

@joeytwiddle
Copy link

joeytwiddle commented Aug 19, 2016

I believe the owner is more likely to merge documentation than code.

This popular answer recommends that .bash_profile should always source .bashrc.

Perhaps the installation instructions should recommend using .bashrc but also recommend ensuring that .bash_profile sources .bashrc, for users with "misconfigured" files.

CentOS has no .profile but always sources .bashrc from .bash_profile. Debian does the same as Ubuntu in .profile (see previous comment).

(By the way, we could even detect an interactive shell like this.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants