1

after some time working in the terminal when it gets flooded with all the commands that i have previously entered and the outputs, i clear the terminal with clear, clear-host, or cls. this clears the terminal but sometimes it does not completely clear the terminal and when you scroll up the terminal you could see remaining of the commands and outputs. on top of it says * History restored. i want to get rid of this as well and make a fresh-looking terminal. is there any ways that i could toggle between the history restoring option? btw i use powershell from vs-code terminal if this info helps. i know there is an option called kill terminal which clears and deletes the terminal but i dont think thats the 'programmer' way of doing it so im seeking for knowledge on any other alternatives.

  • 2
    are you talking about the PowerShell on its own, or an integrated terminal like VS has? – Abraham Zinala Aug 27 '22 at 05:05
  • 1
    powershell a **shell** so it has nothing to do with the scrollback buffer. Only the **terminal** is relevant, for example Windows Terminal, VS code terminal, cmder, or conhost.exe in older Windows... A shell will be attached to a terminal when running – phuclv Aug 27 '22 at 05:17
  • You are not providing enough info. What terminal are you talking about, where you are running PowerShell? powershell.exe, pwsh.exe, Windows Terminal. What OS? What kind of profile settings do you have in place? etc... – postanote Aug 27 '22 at 09:22
  • @postanote my system is running on windows 10 and i run these commands from the integrated powershell in vscode terminal –  Aug 27 '22 at 09:32
  • OK, that's the required info. Yet, as others have said, this is not a PS issue. It's VSCode settings. You still have not said, what your VSC user settings are as well as PSReadLine. So, pull up the VSC and PSReadLine documentation, review the settings and implement from there. Use your favorite search engine to look up how to clear VSC terminals. Linux users are used to this scrolling thing, we Windows folks, not so much. – postanote Aug 27 '22 at 09:49

1 Answers1

0

The question has been asked several times on SO, and all over the web. So, your post can be seen as a duplicate.

Using your browser:

site:https://stackoverflow.com 'clear vs code terminal history'

First hits:

How to clear terminal command history in VS code?

How can I clear the terminal in Visual Studio Code?

As you can read from the above, it is not PS, you'd get this result using other language/tools as well.

Again, the SO threads on the topic exist. Just use the SO searchbox above.

postanote
  • 15,138
  • 2
  • 14
  • 25