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

bash.bashrc: Update PS1 if PS1 wasn't exported. #654

Merged
merged 1 commit into from Jul 15, 2016

Conversation

Karlson2k
Copy link
Contributor

@Karlson2k Karlson2k commented Jul 14, 2016

Should fix regression introduced by #651

bash use some default value for PS1, but this value is not exported. This allow us to distinguish between user-defined PS1 and bash automatic default PS1.

@PhilipOakley
Copy link
Contributor

@Karlson2k Many thanks. That does appear to fix the G4W SDK (I've only done a pacman -Syu the appropriate number of times to get all the changes, and then repeatedly started the SDK shortcut, and I'm getting the right $TITLEPREFIX that's generated by the git bash being properly shown (the difference is "SDK-32" vs "MINGW32" in the title bar)

Also the start paths differ (correctly) of "/" vs "~".

Many thanks.

@PhilipOakley
Copy link
Contributor

@Alexpux Just to say I spoke too soon, and while my initial monkey patch fix git-for-windows/build-extra#122. to G4W still works, reverting that fix doesn't (I reinstalled the SDK from scratch to check, which I hope was sufficient).

What's not clear to me is whether you require that PS1 settings should be exported by/from the bash.bashrc, or whether they should propagate naturally. There appears to be far more nuance in that part of the set up than I currently understand (and lots of stackexchange questions on the subject).

Half the web instructions for setting PS1 don't say export while others do, so it looks like a its quite confused.

Do you require/expect that all PS1 settings should be exported?

@Karlson2k Karlson2k deleted the PS1_fix_01 branch July 16, 2016 17:52
@Karlson2k
Copy link
Contributor Author

@PhilipOakley Sorry, didn't get.
Could you describe what exactly is not working on currently?

If you export your PS1 variable before sourcing bash.bashrc then it will not be overridden. If you just set PS1 to any value and not export it, it will be set to Msys's default value by bash.bashrc.

@PhilipOakley
Copy link
Contributor

@Karlson2k, thanks for getting back.

In git for windows, and the G4W SDK, the PS1 is set within the bash.bashrc file (inserted at the end by an install patch) by dot sourcing a git-prompt.sh script (the link is to the one with my monkey patch).

That PS1 string does two things, first it sets a TITLEPREFIX for the window (so one can tell which window (SDK or MinGW) is which!), and second, adds the regular __git_ps1 promt function to also show the current checked out branch etc. Note that it doesn't export the PS1. I don't (personally) set the PS1 at all (to the best of my knowledge).

As I understand it, you/we shouldn't need to export the PS1 from the bash.bashrc (and files it dot sources) because all subsequent interactive shells will invoke it anyway, so the PS1 will be set anyway e.g. this explicit comment

What I'm seeing is that my window title bars are not displaying the TITLEPREFIX, indicating 'something has gone wrong'. That was the root cause of all these issues way back at dschos comment, which is where I noticed the 'fix' by renatosilva. It's seems like we've been digging holes from that point.

While my monkey patch fix to G4W (mentioned above) fixed the issue on the surface, I tried to understand and fix the base issue (and probably making some mistakes on the way). At the moment I'm still not sure what the root cause was, and if it's fixed.

Additionally, I know that G4W does a liitle bit of a two-step when starting to get the mintty window going properly, and there are comments in the release notes about needing winpty for some apps, so there maybe a rece/cascade issue in setting the PS1 (e.g. the setting seen on the display was set by a previous instance during startup - one window close and another opens...)

So, all in all, things aren't as clear as they could be.

For example,

  1. Should the file dot sourced from the end of the bash,bashrc have the final say on the PS1 value? [Y/n]
  2. Should the PS1 set in the bash.bashrc, and it's dot sourced files, be exported (or not!). [y/N]
  3. What should the bash.bashrc file do if it detects a previously exported PS1?
  4. And what about an exported MSYS2_PS1 seeking to gain priority?
  5. Ss the G4W install patch too assertive in how it modifies the PS1?

(for the first two I've shown what I think my reseach tells me)

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

Successfully merging this pull request may close these issues.

None yet

3 participants