question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debug Session Clutters Terminal Command History

See original GitHub issue

System Details

  • Operating system name and version:
  • VS Code version:
  • PowerShell extension version:
  • Output from $PSVersionTable:


PS C:\Temp> code -v
1.13.0
376c52b955428d205459bea6619fc161fc8faacf
PS C:\Temp> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      3      2      0


PS C:\Temp> code --list-extensions --show-versions
ms-vscode.PowerShell@1.3.2
ms-vsts.team@1.118.2
PS C:\Temp> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14393.1198
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.1198
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

I am experiencing a problem with commands being inserted into the command history by a debugging session. The additional commands seem to be related to the debugging session. I have reproduced this issue with a simple .ps1 file containing a single variable assignment, with a breakpoint set on the line.

Repro.ps1: $x=1

The entires I’m referring to are Ids 5-9 in the below transcript. The “Get-Variable” entries in the command history appear to be triggered by hovering the mouse over a variable in the editor window to view its value. I’m not sure what triggers the ones.

PS C:\Projects\SQLServerDBA\PowerShellModulesV2> c:\Temp\repro.ps1


PS C:\Temp> get-history

  Id CommandLine
  -- -----------
   1 get-module
   2 gci c:\temp\
   3 c:\Temp\repro.ps1


PS C:\Temp> c:\Temp\repro.ps1



Hit Line breakpoint on 'C:\Temp\repro.ps1:1'

[DBG]: [DBG]: PS C:\Temp>
PS C:\Temp> Get-history

  Id CommandLine
  -- -----------
   1 get-module
   2 gci c:\temp\
   3 c:\Temp\repro.ps1
   4 get-history
   5 @{ 'computerName' = $env:ComputerName; 'processId' = $PID; 'instanceId'...
   6 Get-Variable
   7 Get-Variable
   8 $global:__psEditorServices_CallStack = Get-PSCallStack; $global:__psEdi...
   9 Get-Variable
  10 c:\Temp\repro.ps1

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
daviwilcommented, Jun 13, 2017

Thanks Mike! This is coming from PowerShell, I had filed a bug on it some time ago:

https://github.com/PowerShell/PowerShell/issues/3109

I’ll see if I can find a workaround that doesn’t cause these commands to be added to your history.

0reactions
andschwacommented, Sep 2, 2022

Hey @TheOnlyWei can you test the latest release and let me know both what you see and how you test it? I’d like to get this finished if I can.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command History (Debugging with GDB) - sourceware.org
GDB can keep track of the commands you type during your debugging sessions, so that you can be certain of precisely what happened....
Read more >
History command inside bash script - Unix StackExchange
If you're debugging a script then shell history is not the best way to get useful information. A much better tool is the...
Read more >
15 Examples To Master Linux Command Line History
15. Ignore specific commands from the history using HISTIGNORE. Sometimes you may not want to clutter your history with basic commands such as ......
Read more >
How to manage your Linux command history | Enable Sysadmin
In Bash, your command history is stored in a file ( .bash_history ) in your home directory. The leading (.) makes the file...
Read more >
Debugging with GDB
Once started, GDB reads commands from the terminal until you tell it to exit. ... Future GDB debugging sessions notice the presence of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found