DGRFDSGN
DGRFDSGN

Reputation: 675

Visual Studio Code / powershell commands History up key

In what way could I log my previously entered commands in visual studio code? For instance when I press up key I can up through all my previous commands, I would like to log these to a file if possible.

Where are they stored locally? Could I log it with something like node?

Upvotes: 4

Views: 4737

Answers (2)

DGRFDSGN
DGRFDSGN

Reputation: 675

I've actually solved this myself thanks to the help of @bruce-payette and @robdy for pointing me in new directions. Logging all commands, also from previous sessions, can be done from PowerShell itself. Enter this command in PowerShell to recieve the path to a file where PowerShell saves the history accessible by using the up key:

(Get-PSReadlineOption).HistorySavePath

This will output something like this:

C:\Users\[username]\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt

Open this file to see all saved commands from previous sessions!

Upvotes: 9

Bruce Payette
Bruce Payette

Reputation: 2629

The cmdlet Get-History will give you the history of the commands you've run. You can save this to a file by doing

Get-History | Out-File myhistory.txt

Upvotes: 2

Related Questions