-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add a terminal-side shortcut for clearing the screen and/or scrollback #1882
Comments
Why just clear screen? Why not a toolbar where common commands can be added as quick shortcuts? |
But, this isn't a bash command, as I think that's what you are asking. Command+K on a mac doesn't run any commands in the terminal such as "clear"... it clears the entire terminal buffer. Commands such as "clear" don't do the equivalent. I personally don't need a toolbar - I'm fine with adding them to the "Settings.json" file like all the other keyboard shortcuts. Its just that "Clear terminal" is not one of the available options to create a shortcut for. If you use VSCode, the exact equivalent command is "Terminal:Clear". I map that to Alt+K to get the same experience. |
Are we not talking about the same thing as issue # 1189 ? |
@fzed51 Nope, this is unrelated to that one. To clarify for future me - cmd+k is not something that's being handled by You've described a user story that makes sense to me, so I'm gonna put this on the backlog.
|
I would like to help with that if possible, shouldn't be so difficult right? I mean can be just reset the buffer and initialize again the buffer |
You should definitely read the comments here. Because of the windows console infrastructure we’re built on it’s not quite that easy. |
Ok, I don't have any idea about the internals of the terminal, however, if in order to clear a buffer after press a key combination is so complex probably it will be impossible to scale the product when adding more complex stuff than this |
It's just this issue in particular that's thornier than most. For compatibility with Windows console applications that do not expect a terminal to be connected, we need to maintain a text buffer for them to read. That's all. Because we don't have a way to clear that text buffer (from the terminal side), and we just haven't written one yet, it's only more complex than clearing the local screen. It's not a complexity class issue with all of Terminal. |
Gotcha, thanks for the clarification, definitely isn't a beginners task |
I'm discovering this while switching to this terminal and this is really annoying. So big 👍 for a keystroke as I understand that Thinking about it, also, as a nice improvement, maybe it is something that has a feature request on its own, but a "bird-view" side pane on the right side where we could spot easily where commands are and where are the outputs would be also super useful... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
On my terminal, it worked by input |
I have created a workaround which worked on WSL/bash, SSH/bash (Linux tested) and PowerShell 7 for me with CTRL+ALT+K: { "command": { "action": "sendInput", "input": "\u001B[H#\rtput reset || printf '\e[1J\e[3J\e[r'|| Clear-Host\r\u001B[A\u001B[A\u001B[H\u001B[3~\u001B[F" }, "name":"Clear screen and Scrollback", "keys": "ctrl+alt+k" }, These steps will done with sendInput action:
For me the history and scrollback are cleared |
open a second tab? |
I have a running process that is logging to the console, but since it is logging too much things and I just want to concentrate in newer lines I just want to clear the screen so new lines don't get confused with older ones. A new tab doesn't work for this case |
Second tab doesn't work for many cases. SSH sessions, tail -f, long CWD you don't want to type again and again – to start with. |
Any updates on this? Still annoying that there is no clear scrollback option. That's the only thing stopping me from uninstalling MobaXTerm |
Others have noted that the command |
Unfortunately, I need to reset the cursor position, and I actually just need to do this differently entirely. iTerm actually maintains the last line of the buffer entirely. That's kind of important! Otherwise the prompt just disappears too. They're actually even smarter than that: * https://gitlab.com/gnachman/iterm2/-/issues/1330 * https://gitlab.com/gnachman/iterm2/-/issues/4393 and know where the prompt starts and ends, and keep all of multi-line prompts. That's a very 2023 feature, but we should keep at least one line.
There are other details in #1193 for those interested in the technical bits. |
Nice work! This works while running a "ping google.com -t"? Thanks |
…buffer (#10906) ## Summary of the Pull Request ![clear-buffer-000](https://user-images.githubusercontent.com/18356694/127570078-90c6089e-0430-4dfc-bcd4-a0cde20c9167.gif) This adds a new action, `clearBuffer`. It accepts 3 values for the `clear` type: * `"clear": "screen"`: Clear the terminal viewport content. Leaves the scrollback untouched. Moves the cursor row to the top of the viewport (unmodified). * `"clear": "scrollback"`: Clear the scrollback. Leaves the viewport untouched. * `"clear": "all"`: (**default**) Clear the scrollback and the visible viewport. Moves the cursor row to the top of the viewport (unmodified). "Clear Buffer" has also been added to `defaults.json`. ## References * From microsoft/vscode#75141 originally ## PR Checklist * [x] Closes #1193 * [x] Closes #1882 * [x] I work here * [x] Tests added/passed * [ ] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments This is a bit tricky, because we need to plumb it all the way through conpty to clear the buffer. If we don't, then conpty will immediately just redraw the screen. So this sends a signal to the attached conpty, and then waits for conpty to draw the updated, cleared, screen back to us. ## Validation Steps Performed * works for each of the three clear types as expected * tests pass. * works even with `ping -t 8.8.8.8` as you'd hope.
I'm sort of confused, I'm hitting |
1.12 should be the first version that has this feature. |
ah got it, thank you! can't wait! |
🎉This issue was addressed in #10906, which has now been successfully released as Handy links: |
It would be great to have the equivalent of Command+K on the Mac terminal. This clears the terminal completely, not the equivalent of typing "clear", which only scrolls the cursor to the top of the terminal. My use case is the following:
The text was updated successfully, but these errors were encountered: