Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to alias 'clear' to CTRL+L keystroke

Tags:

alias

bash

I have a habit of issuing the clear command.

When I run cygwin, the package containing clear isn't installed and I don't have the option of installing it. Ctrl+L is a good substitute; however, I still issue the clear command habitually.

I'd like to alias the clear keyword to issue the Ctrl+L keystroke. Is this possible to achieve in the .bashrc file, or something of the like?

Thanks!

like image 248
tomocafe Avatar asked Dec 15 '22 07:12

tomocafe


1 Answers

clear clears the screen simply by outputting some ANSI escapes sequences. You can do the same thing with printf:

alias clear='printf "\e[H\e[2J"'
like image 100
that other guy Avatar answered Jan 02 '23 11:01

that other guy