-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Some shells don't remember history #151105
Comments
This type of issue has been reported a few times and I think we've closed them all out, let's track in this one. This works fine in pwsh, I believe this is because pwsh persists history to disk as you type, whereas git bash does it when the process shuts down. Something about how we're shutting down the terminal processes doesn't let git bash persist to disk. Maybe the problem code is here where we kill all processes before closing the conpty pty: https://github.com/microsoft/node-pty/blob/1674722e1caf3ff4dd52438b70ed68d46af83a6d/src/windowsPtyAgent.ts#L161-L168 We tweaked what happens here a bunch to try stop processes leaking which is why we go through and kill all processes in |
Ok sure. It would be great if we'll have a solution here. But this is working perfectly fine on my Macbook Air. So we would like to have this on Windows PC too. Thanks in advance. |
As far as I understand the problem at its root for Git bash integration it indeed appears to be related to:
However, the VSCode integration of Git Bash has further, compounding issues: The Git Bash Windows Terminal Profile Fragment vs. VS Code's definition reveals that VSCode doesn't start the Git Bash as However, as I outlined in the discussion post … that is sadly not enough and the |
Bash sessions should be started as interactive (`-i`) sessions to enable history commands by default. This is the same setup used by the official Git for Windows JSON fragment extension for Windows Terminal. This does not fix the issue at this time, however, because bash signal handling on Windows for quit/close/kill signals does not work as expected.
The situation might be better in newer versions of Windows when microsoft/terminal#14282 ships. We'll probably need to tweak node-pty's process kill logic though. |
A couple I found by googling " Today I encountered a Stack Overflow question about a user experiencing the same issue with a Zsh shell. I found I that I experience the same issue with a Bash shell on Ubuntu with VS Code 1.77.1 installed as a Snap. My Bash shell in the VS Code interactive terminal is an interactive, non-login shell. Opening a login sub-shell with Let me know if I should create a new issue ticket that is not specific to Windows (since this one currently is). Loosely related in the Window Terminal repo: microsoft/terminal#7826. |
I have this problem on VSCode in MacOS/Darwin. The root cause is easily replicated by setting When exiting VSCode, if the persist setting is set to "never" or is "onExit" and the window is closed, then the terminal should follow the normal exit procedures and logout properly. |
This is an older issue, but I'm hoping that this gets fixed reasonably soon. VSCode is practically unusable for me as it is. |
Same problem here for zsh on MacOS, not always though. Haven't figured out when or why it happens, but sometimes the integrated terminal in VSCode only shows history of the regular terminal. |
Shells generally have different behaviour concerning histories and VSCode simply exacerbates it by not closing them correctly, especially on Windows in particular (afaik). Bash will generally only save the history for the last interactive ( In case of ZSH there are options such as setting To verify what goes wrong on macOS and help debugging efforts you should verify the Terminal setup in VSCode and add that information here. |
The SHARE_HISTORY option seems to work for me as a fix. Closing the terminal by typing "exit" also seems to work. This wasn't necessary earlier though. As far as I know I'm using defaults for the terminal. I just checked it with a VSCode Insiders download without any plugin or setting changes and I had the same problem there. Tldr, for now use "exit" every time to save history, or: |
I had this issue and seemed to only impact vscode (terminal in macos commands were saved and subsequently available in vscode later)... the comment mentioned above by Okeanos to add "export PROMPT_COMMAND='history -a'" (I added this in to ~/.bash_profile) finally seemed to be the thing that made VScode terminal bash sessions remember history regardless of how VSCode was exited and/or which folder I opened, basically making it seem normal again. Of note, I did have a messy bash_profile and this command was already in there, but cleaning up the garbage and leaving the command revived it. Mentioning that in case anyone says they have the command already in there, maybe a troubleshooting step to backup file and leave only that command and work backwards from there. I did several other troubleshooting steps like clearing the history in ~/.bash_history so I can't say absolutely that this specifically fixed it but am about 98% sure. Hope the details help whomever try and resolve. |
@sfboss |
Wouldn’t they appreciate the information to try and resolve the issue? By
no means am I advocating for people to give up trying to fix it to use a
workaround and I apologize for missing credit on your previous info.
I am honestly asking if I should not add things like this to issues in the
future as this is the first time I ever commented in a long time. My
thoughts were it would help people needing a workaround while getting it
fixed fully and/or details to help narrow down a full fix.
Let me know if there is some other way to get that info across or what as
I’d like to make meaningful contributions.
…On Sat, May 13, 2023 at 11:06 PM starball ***@***.***> wrote:
@sfboss <https://github.com/sfboss> export PROMPT_COMMAND='history -a' is
a documented workaround. see also my prior comment
<#151105 (comment)>,
what states that. As far as I understand, this issue ticket is about fixing
the problem instead of using workarounds.
—
Reply to this email directly, view it on GitHub
<#151105 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWZZYZQMQF2BDWDB5RLILE3XGBY7TANCNFSM5XVDUZUA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
They wrote the docs that state that that is a known workaround. I.e. I'm saying they already know what you're telling them. |
I'm getting the same issue on Mac M1 Ventura 13.2 with VSCode v1.78.2 and zsh shell. This started happening when I updated VSCode to the latest version. |
Recent fix in this area #181508, can you repro in insider's? |
Hello thanks for the update and the PR @meganrogge. Could you help me figure out how I can test it? |
You can install vscode insiders to test it |
fwiw, in linux, i figured vscode internal terminal created a .zsh_history when the commands from my native terminal were stored in .zhistory. |
What is the workaround for windows with git bash? Typing exit manually seems to work, but it is obviously tedious. Where do I have to set export PROMPT_COMMAND='history -a' on windows for git bash? |
You should be able to set it in |
Thanks that worked! Neither file existed, so I created |
This is non-intuitive behavior to have within vscode even if it is emulating something on linux. Would be nice to have it as default for consistency. |
First of all, thanks to @KaivG for guiding me to the following solution.
|
Does this issue occur when all extensions are disabled?: Yes
Steps to Reproduce:
When I pressed the top arrow key It shows like so. But no idea from where that CLI is coming. I would like to have
npx cap open android
CLI here.The text was updated successfully, but these errors were encountered: