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

Pane history not being saved (GitBash) #11697

Open
oshihirii opened this issue Nov 6, 2021 · 9 comments
Open

Pane history not being saved (GitBash) #11697

oshihirii opened this issue Nov 6, 2021 · 9 comments
Assignees
Labels
Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal.
Milestone

Comments

@oshihirii
Copy link

oshihirii commented Nov 6, 2021

Windows Terminal version (or Windows build number)

Windows 10 , Version 21H1 (OS Build 19043.1288)
Windows Terminal Preview Version: 1.12.2931.0

Other Software

Git 2.33.1

Steps to reproduce

I have three Git Bash panes in my Windows Terminal Preview setup.

I close Windows Terminal Preview by clicking the X button in top right of application.

When I re-open, my most recent history is not accessible in any of these three panes (ie pressing the up and down arrows on the command line).

It seems to have saved history from before I installed Windows Terminal Preview.

I have a .bash_history file in C:\Users\Me and I can see the history entries in that file.

I don't seem to have a .bash_profile file in that location (as related answers on stack overflow have suggested looking at).

Expected Behavior

No response

Actual Behavior

See Steps to reproduce section.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Nov 6, 2021
@oshihirii
Copy link
Author

I don't know if it is the correct thing to do, but I created a file called .bash_profile at C:\Users\Me with this content:

PROMPT_COMMAND='history -a'  

Per this answer:

https://stackoverflow.com/a/10901227

And now I can access recent command history.

@zadjii-msft
Copy link
Member

Weird. That sure is interesting. I wonder if the history gets sabed when you exit bash, rather than hitting the 'X' button on the tab. I think we've seen that before somewhere actually....

Glad you got this sorted out though!

@zadjii-msft zadjii-msft added Issue-Question For questions or discussion Resolution-Answered Related to questions that have been answered labels Nov 8, 2021
@oshihirii
Copy link
Author

just fyi - i tested and if i type exit it closes the pane (as you suggested - the entries are saved in .bash_history).

however that is not desired behaviour as i'd like to retain all the panes in their defined positions when i next open the app.

doing the above steps requires resetting up panes when re-opening the app.

@oshihirii
Copy link
Author

just updating that this is still happening as at 15/04/22.

i am now running it on a new laptop and again found myself searching for "windows terminal preview not saving history".

@theHilikus
Copy link

theHilikus commented Oct 18, 2022

any idea why this workaround is actually needed? having to change your bash history mode to save on every command seems overkill. the problem seems to me to be that Windows Terminal is not exiting cleanly the session when you use the UI. if i do exit or ctrl+d it is persisted properly but not if i click X

Weird thing is that I have WSL2 configured and that one persists the history, but the one for git bash does not

seems to be similar to microsoft/vscode#39877 where indeed VScode is not exiting the session cleanly

@DHowett
Copy link
Member

DHowett commented Oct 18, 2022

I'm gonna reopen this for triage again. Thanks!

@DHowett DHowett reopened this Oct 18, 2022
@Okeanos
Copy link

Okeanos commented Nov 5, 2022

@DHowett I had a look at that the problem of Terminal not persisting Git Bash history while ago as well and wrote down my thoughts here.

TL;DR: it appears that git-bash.exe supplied by Git for Windows (MinTTY in particular only) handles signal handling differently than Windows Terminal (or VSCode for that matter) and will properly exit out of bash.exe. VSCode additionally suffers from not starting Git Bash as interactive session (which is required for automatic history handling; see microsoft/vscode#151105).

@DHowett
Copy link
Member

DHowett commented Nov 9, 2022

Thanks for the investigation! We're looking at some other teardown issues... idly I wonder if #14282 will help. 😄

@oshihirii
Copy link
Author

I don't know if it is the correct thing to do, but I created a file called .bash_profile at C:\Users\Me with this content:

PROMPT_COMMAND='history -a'  

Per this answer:

https://stackoverflow.com/a/10901227

And now I can access recent command history.

Just noting, I have switched to another PC and found myself googling this issue again:

windows terminal preview not saving bash history

The environment is:

  • Windows Terminal Preview: Version: 1.16.3464.0
  • Windows 11 Home

I got it working by doing the workaround I posted above on 06/11/21.

Someone down-thumbed that post though, so maybe it's not a good thing to do 😢

@carlos-zamora carlos-zamora added Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. and removed Issue-Question For questions or discussion Resolution-Answered Related to questions that have been answered Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Aug 9, 2023
@carlos-zamora carlos-zamora added this to the Backlog milestone Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

6 participants