-
-
Notifications
You must be signed in to change notification settings - Fork 295
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
Add zsh terminal prompt support #722
Conversation
|
I have tested every bit I could think of: reading from I have seen there has been discussions on reading alias trac 4007 and in comments on #170 –– I took the liberty to "hardcode" the path to |
|
Come to think of it: the |
02a9cd1
to
353ab28
Compare
|
Latest update will produce a result like: I can't help myself fiddling with this, would appreciate if someone took a look at this and put an end to it 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make zsh fully supported, you can also add it to g.mapset to provide a proper "fix history message":
https://github.com/OSGeo/grass/blob/master/general/g.mapset/main.c#L208
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The visual result is up to you, so if this what you prefer or what is technically possible, I'm fine with that.
About the similarities with Bash, I'm not comfortable with the large overlap, but I don't have any good solution to account for the tiny differences all over the place.
As for the behavior with rc files and aliases, sourcing sounds good, but I can't quite get the whole picture at this point reading again discussion in #170. Perhaps @HuidaeCho has a better idea.
But still, looking on the quotations in #170, have you tried not doing the HOME change hack? The statement there by Glynn Clements ("AFAICT, the reason for messing about with the shell startup was to force the use of per-mapset history files") suggests that if history is handled through other means (here HISTFILE), the HOME hack is not needed, doesn't it?
Just curious if there are major differences between bash and zsh to require separate but substantially overlapping code. Looking at
Currently, all this startup code is a little bit messy. For example, like @wenzeslaus mentioned in #2681, For bash, I didn't source
Exactly! It would be ideal to remove the HOME hack altogether. Why not just set |
|
Thanks @wenzeslaus and @HuidaeCho for taking time and effort to look into this. As I mentioned in initial comment an option would be to merge the two functions into one as you both also mentioned. Now I did that in last push. Contrary to my fear, I believe this didn't lead to a too complicated code. Regarding avoiding the HOME hack. I have not yet tried it, but I'm confident it is feasible. Yet perhaps not a trivial one, better left for GRASS 8 I believe. My hope for this PR is to backport it to 7.8 as well (one reason I initially added a separate method for zsh). Apart from setting HISTFILE, measures has to done to contrive support for the various shells (for setting prompts etc.). I changed the prompt for zsh to look a bit more like bash: the mask info (the PROMPT_COMMAND) is only printed if set, as now is the case for bash. But I lifted the location from PS1 and added this to RPROMPT together with mapset. The reason for this is that the prompt can be very long with a long location name and this in particular when working directory is not home, and I miss the mapset. I sneaked in a fix for trac issue 3009 (failure to quit GRASS from GUI on macOS and FreeBSD) adding |
Thanks for the reminder. Added. |
|
@lbartoletti It would be great if you could test this on FreeBSD, if the zsh prompt works at all, but also if the GUI "Quit GRASS" (see #408 for previous discussion) works (with bash or zsh). In case a condition will be needed, what result gives python command |
|
I suggest to move ahead with this. I agree that the alias. history, and fake home situation should be resolved and we made advancements in our understanding, but let's resolve that in another PR. Same for wrapping all shells functions into one (or whatever is what you are heading towards). It seems to me that original intention and necessary code refactoring are done. This conflicts with #768 which I would like to merge, but it already conflicts with master branch, so I though it would be easier to merge this first and then resolve all conflicts in #768. Alternatively, I can merge #768 and you (@nilason) resolve the conflict here (should be mostly indentation). |
|
I updated following suggestions from you both, as I deemed correct. Please do (re-)raise any remaining issue you might have. Also, please do address the previously mentioned issue:
This could be enclosed in something like: |
|
Thanks @nilason . Bash and zsh work for me. The GUI exit works for me on Linux. History works only with bash, not with zsh. However, this is an improvement as it is, so I merged and will leave it on you or others to open new issues or PRs. |
|
@HuidaeCho and @wenzeslaus Thanks!
Thats the problem with not being able to test on different platforms. For a quick check @wenzeslaus, could you please run in a zsh terminal |
|
|
Thanks for checking! Suspected something like that. Shouldn't be too complicated to fix. Will put a new PR. |
|
Shall this be backported, @nilason ? |
|
That would be preferable :), zsh is the default mac terminal shell from latest OS version (10.15). This might have side effect on bash too, but is on master for two weeks now, so maybe safe. In any case, a backport label could do for now. |
Adds zsh terminal prompt support and includes history change message for zsh in g.mapset. Fixes #719.
|
I have backported it, please test it. |
Great, thanks! Will test it. |
This addresses #719, regarding missing GRASS specific terminal prompt with zsh.
The code is more-or-less a copy of
bash_startup()withbashreplaced withzshat appropriate places and adoptedPS1to zsh.This seems to work as is, but
zsh_startup()might be merged withbash_startup()using variables and I'm not familiar with every part of the code (and how to test it) – I therefore leave this as WIP.For testing this PR : do
chsh -s $(which zsh)and open new terminal.