powershellterminalvisual-studio-code

How to clear the entire terminal (PowerShell)


I had an issue. Using the clear or cls command in powershell clears only the visible portion of the terminal,I would like to know how to clear the entire terminal?

I use VSCode by the way.


Solution

  • tl;dr


    To also clear the scrollback buffer, not just the visible portion of the terminal in Visual Studio Code's integrated terminal, use one of the following methods:

    {
        "key": "ctrl+k",
        "command": "workbench.action.terminal.clear",
        "when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
    }
    

    Using a command you can invoke from a shell in the integrated terminal:

    Note: A truly cross-platform solution would require executing the VSCode-internal workbench.action.terminal.clear command directly from a shell, but I don't know how to do that / if it is possible at all - do tell us if you know.