简体   繁体   English

如何对CTRL + L按键使用别名“清除”

[英]How to alias 'clear' to CTRL+L keystroke

I have a habit of issuing the clear command. 我有发出clear命令的习惯。

When I run cygwin, the package containing clear isn't installed and I don't have the option of installing it. 当我运行cygwin时,没有安装包含clear的软件包,并且没有安装它的选项。 Ctrl + L is a good substitute; Ctrl + L是一个很好的替代品; however, I still issue the clear command habitually. 但是,我仍然习惯性地发出clear命令。

I'd like to alias the clear keyword to issue the Ctrl + L keystroke. 我想给clear关键字加上别名,以发出Ctrl + L击键。 Is this possible to achieve in the .bashrc file, or something of the like? 是否可以在.bashrc文件或类似文件中实现?

Thanks! 谢谢!

clear clears the screen simply by outputting some ANSI escapes sequences. clear只需输出一些ANSI转义序列即可清除屏幕。 You can do the same thing with printf : 您可以使用printf做同样的事情:

alias clear='printf "\e[H\e[2J"'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM