Powershell Clear-Host替代方案可保留缓冲区 [英] Powershell Clear-Host alternative to preserve the buffer

查看:232
本文介绍了Powershell Clear-Host替代方案可保留缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要类似Clear-Host的东西,但是想要回滚.

I would like something like Clear-Host, but would like the scrollback.

到目前为止,我所拥有的基本上只是添加换行符,直到屏幕清晰为止.虽然在执行此操作时,光标开始在页面底部开始书写(尽管不希望如此,这是可以预期的).

So far, all I have is basically adding newlines until the screen is clear. Though when I do this, the cursor starts writing at the bottom of the page (as to be expect- though not desired).

我希望从页面顶部开始写(对于菜单等,这是很自然的事情)

I would hope to start writing at the top of the page (for menus and such- which is the natural thing to do)

这是打印新行动态计数的代码:

This is the code to print the dynamic count of new lines:

do {Write-Host ""; $i++}
while ($i -ne $Host.UI.RawUI.WindowSize.Height)

我确实看到了有关Transcript模块的内容,但并不希望如此.

I did see something about a Transcript module, but do not desire that.

提前谢谢.

推荐答案

以下是一则帖子,其中提供了您所要查找的内容:

Here's a post which gives exactly what you're looking for:

http://tommymaynard.com/ql-clear-host -无需清除主机/

这篇关于Powershell Clear-Host替代方案可保留缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆