-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bash command to clear the VSCode integrated terminal scrollback on Windows 10? #116664
Comments
Related to xtermjs/xterm.js#106 Not sure we can do anything about this as I believe we handle the sequence we're given correctly. |
You can check what VS Code receives from the pty by logging escape sequences https://github.com/microsoft/vscode/wiki/Terminal-Issues#enabling-escape-sequence-logging |
Thanks Tyriar. I executed this command in bash:
I cleared the dev console during the
Something deleted my
|
Looks like something is going wrong with the emulation here that causes your sequence to get stripped out? When you run printf it would go through git bash and then through conpty before reaching the process, and those layers are passed through again when coming the other direction. You could try:
|
Although this is a really old issue, it's still relevant. Even today, no matter whether I'm running cmd, Powershell 7, Git Bash or any other profile, their respective clear command only clears one screenful of the terminal, without actually clearing the scrollback buffer. |
@TYTheBeast that's tracked in xtermjs/xterm.js#1727 |
Workarround that worked for me in zsh in mac alias clear='printf "\e[3J"; clear' I guess similar approaches can be done with other shells. HTH |
Under cmd.exe inside VSCode, none of the "clear" termcodes will clear the scrollback, even though at least a few of them probably should. In fact, the plain old 'cls' command should clear the scrollback, as it does under the classic cmd window, and also the new Windows Terminal. But, it does not. Here is a @echo off
setlocal enableextensions
call :testit "[3J" "erase scrollback" || exit /b
call :testit "[2J" "erase all" || exit /b
call :testit "[1J" "erase above" || exit /b
call :testit "[0J" "erase below" || exit /b
call :testit "[J" "erase below (alternate)" || exit /b
call :testit "c" "reset term" || exit /b
echo Done.
goto :eof
:testit
REM this loop will probably reach the scrollback on most window sizes
for /l %%F in (30,1,37) do (
for /l %%B in (40,1,47) do (
call :echoe "\x1b[%%F;%%Bm%%F;%%B\x1b[0m"
)
)
echo. & echo.
set /p "_=Press enter to test %1 (%~2): "
if "%_%"=="q" exit /b 1
call :echoe \x1b%1
echo Sending of %1 (%~2) is complete.
if "%~1"=="c" exit /b && REM "(exit because c is the last test)"
set /p "_=Press enter to move on to the next test."
exit /b 0
goto :eof
goto :eof
:echoe
setlocal
set "arg=%~1"
set "arg=%arg:\x=0x%"
forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c <nul set /p _=%arg%"
goto :eof |
Issue Type: Bug
I'm happily running Git bash in VSCode on Windows with:
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
The "Terminal: Clear" command (
workbench.action.terminal.clear
, which I have bound to Control-L) clears not only the screen but also the scrollback buffer, as expected, so trying to scroll up does nothing because there is nothing to show.How can I reproduce this with a shell command?
The
clear
command does not clear the scrollback, neither doesreset
. These commands work by outputting escape sequences to the screen. Since the terminal thinks it is "TERM = xterm-256color", the relevant escape sequence should be the one output by the shell commandprintf "\e[3J"
which works on all other xterm emulations (and is part ofclear
's output). In VSCode it does not clear the scrollback but, oddly, resurrects one screenful of previously cleared scrollback.VS Code version: Code 1.53.2 (622cb03, 2021-02-11T11:48:04.245Z)
OS version: Windows_NT x64 10.0.19042
System Info
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Extensions (4)
A/B Experiments
The text was updated successfully, but these errors were encountered: