You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Get-History command showing history from previous sessions #1074
Apparently there are community-provided solutions for this, but it would be nice to have a built-in solution for saving command history across sessions, similar to Bash.
So, i downloaded and tried PowerShell 6.0.0-beta.7. The desired functionality would be that the history command would show the history from the previous session, without any additional work
Carlton Semple (@CarltonSemple) Correct. Assuming you don't have something in your profile that is disabling PSReadLine, and assuming you are not making any modifications to the default install 6.0.0-beta.7 and 6.0.0-beta.8 should maintain CLI history between sessions.
Mark Kraus (@markekraus) I deleted my profile files just now, and tried 6.0.0-beta.8 .... history and Get-History still don't show CLI history from the previous session for me
Carlton Semple (@CarltonSemple) ah Get-History only provides commands for the current session. However you can use the up arrow to access the commands from the previous session. and there are more options such as searching and such. I'm not a PSReadLine expert.
changed the title [-]Feature Request: Cross session command history[/-][+]Feature Request: `Get-History` command showing history from previous sessions[/+]on Oct 14, 2017
Possibly but the point, I think, is that PSReadline (inspired by GNU Readline), was created to provide such features. Get-History is legacy command that is still useful IMO as more of "audit" trail for the current session. Back in the old days, I use to save the Get-History history to files by adding this to my profile:
I'm not sure if this will work on PowerShell Core. I also had find functions I had defined that could search these history files. I don't use these so much anymore because PSReadline scratched that itch pretty nicely.
I think some parity with bash's history from PSReadLine would be nice to have. I definitely have done history | more a million times trying to trace back the command history to see where things went wrong or when I'm trying to remember a command I don't recall enough of the syntax to make keyword searching the history useful.
Steve Lee (@SteveL-MSFT)Dongbo Wang (@daxian-dbw) Could you please make a conclusion - should we enhance Get-History cmdlet in the repo (change label to Area-Cmdlets-Core) or PSReadline (in the case please move the issue in PSReadline repo)?
Activity
markekraus commentedon Oct 14, 2017
Unless I'm doing something special I'm aware of, doesn't PSReadLine do this by default in Core?
Can you provide what specific bash-like functionality you are looking for?
lzybkr commentedon Oct 14, 2017
Yes, PSReadLine does this by default.
CarltonSemple commentedon Oct 14, 2017
So, i downloaded and tried PowerShell 6.0.0-beta.7. The desired functionality would be that the
historycommand would show the history from the previous session, without any additional workmarkekraus commentedon Oct 14, 2017
Carlton Semple (@CarltonSemple) Correct. Assuming you don't have something in your profile that is disabling PSReadLine, and assuming you are not making any modifications to the default install
6.0.0-beta.7and6.0.0-beta.8should maintain CLI history between sessions.CarltonSemple commentedon Oct 14, 2017
Mark Kraus (@markekraus) I deleted my profile files just now, and tried 6.0.0-beta.8 ....
historyandGet-Historystill don't show CLI history from the previous session for meCarltonSemple commentedon Oct 14, 2017
I'm using Windows 10
markekraus commentedon Oct 14, 2017
Carlton Semple (@CarltonSemple) ah
Get-Historyonly provides commands for the current session. However you can use the up arrow to access the commands from the previous session. and there are more options such as searching and such. I'm not a PSReadLine expert.rkeithhill commentedon Oct 14, 2017
You can search backwards with Ctrl+r. If you go too far, use Ctrl+s to move forward through the matching history list.
CarltonSemple commentedon Oct 14, 2017
Mark Kraus (@markekraus) I guess maybe I should change the title to specifically reference the
Get-Historycommand, then.[-]Feature Request: Cross session command history[/-][+]Feature Request: `Get-History` command showing history from previous sessions[/+]rkeithhill commentedon Oct 14, 2017
Possibly but the point, I think, is that PSReadline (inspired by GNU Readline), was created to provide such features.
Get-Historyis legacy command that is still useful IMO as more of "audit" trail for the current session. Back in the old days, I use to save theGet-Historyhistory to files by adding this to my profile:I'm not sure if this will work on PowerShell Core. I also had find functions I had defined that could search these history files. I don't use these so much anymore because PSReadline scratched that itch pretty nicely.
markekraus commentedon Oct 14, 2017
I think some parity with bash's
historyfrom PSReadLine would be nice to have. I definitely have donehistory | morea million times trying to trace back the command history to see where things went wrong or when I'm trying to remember a command I don't recall enough of the syntax to make keyword searching the history useful.iSazonov commentedon Sep 28, 2019
Steve Lee (@SteveL-MSFT) Dongbo Wang (@daxian-dbw) Could you please make a conclusion - should we enhance Get-History cmdlet in the repo (change label to Area-Cmdlets-Core) or PSReadline (in the case please move the issue in PSReadline repo)?
espoelstra commentedon Dec 4, 2019
See also the "Dangers" of this indefinite history. https://www.windowsmanagementexperts.com/the-danger-of-default-settings-the-psreadline-module/the-danger-of-default-settings-the-psreadline-module.htm