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

Can Git bash save command history when window closed? #2073

Closed
1 task done
dougbreaux opened this issue Feb 14, 2019 · 3 comments
Closed
1 task done

Can Git bash save command history when window closed? #2073

dougbreaux opened this issue Feb 14, 2019 · 3 comments
Labels

Comments

@dougbreaux
Copy link

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.20.1.windows.1
cpu: x86_64
built from commit: 7c9fbc07db0e2939b36095df45864b8cda19b64f
sizeof-long: 4
sizeof-size_t: 8
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.17763.292]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
$ cat /etc/install-options.txt
Editor Option: Notepad++
Custom Editor Path:
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

None

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Bash

N/A

  • What did you expect to occur after running these commands?

Bash command history saved immediately, regardless of how the shell is closed.

  • What actually happened instead?

Bash command history is only saved on a graceful exit. Not on window close, which means not when Windows updates cause a reboot.

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

N/A

@landstander668
Copy link

This is actually normal unix/linux behaviour, which MSYS2 is faithfully emulating on Windows. The typical workaround I've seen is to add export PROMPT_COMMAND='history -a' to your bash initialization file(s). It looks like Git Bash launches BASH as a logon shell, so ~/.bash_profile is most likely where you want to do this.

This causes the history -a command to be run every time the shell prompt is displayed, which flushes pending updates to the file.

@dougbreaux
Copy link
Author

Ok. Seems weird and inefficient, but if that's all I'm going to get ... :-)

@shiraze
Copy link

shiraze commented Jan 30, 2024

Duplicate of microsoft/vscode#151105?

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

No branches or pull requests

4 participants