Search code examples
windowscmdkeyboard-shortcutswindows-terminal

Keyboard shortcut to clear the cmd and windows-terminal


I am looking for a keyboard shortcut for the "cls" command under windows as for the terminal on mac with:

+ K

Command + K for newer keyboards

Someone would have any idea ?


Solution

  • there is no keyboard shortcut dedicated to the "cls" command. However, you can create it yourself as follows: (you can see the following gist

    1. you must first download the tool autohotkey
    2. Install it
    3. Create an empty file with the extension ".ahk"
    4. Fill the script with the following code to have the shortcut Ctrl + k (You can choose the shortcut that suits you):

    Script

    #IfWinActive ahk_class ConsoleWindowClass
    ^K::
    Send cls{Enter}
    return
    
    1. Save and run the file by double clicking

    Note:

    This shortcut is no longer valid as soon as you close the current session, so I recommend that you move the file to a special folder which will run the script each time you start windows, here are the steps:

    1. Copy the script file
    2. Type Windows key + R
    3. Execute shell:startup
    4. Paste the file