cygwin clearscreen from bash

前端 未结 7 813
说谎
说谎 2021-01-30 21:00

I want to clearscreen from bash in a cygwin terminal. I have tried

cmd /c cls
echo -e \"^V^L\"
echo -e \"\\014\"

None of these work - they all

相关标签:
7条回答
  • 2021-01-30 21:06

    I was trying to do something similar and upon researching I found the above answers, I tried to follow some of the above solutions, I added the line to .bashrc, but it did not accept the function, I tweaked around and found out another solution...it basically executes the ' printf "\33c" but instead of tweaking the .bash.rc file, you simply go to the directory - /cygwin/bin , Write the following command :- printf "\033c" And save it with the filename "cls" , in the bin directory, ensure that there is NO EXTENSION to the file, thus it will have the type "file" ..save it,open the shell and the command will run...

    I found this method by playing around with msys and cygwin, I have both on my windows PC and turns out msys supports the "cls" command, I found a file with the same name in it's bin directory and copied it to the cygwin's bin folder and edited the file with the printf function and this worked like a charm...hope this helps.

    0 讨论(0)
  • 2021-01-30 21:09

    If it's contained in your cygwin install (run Cygwin's setup and make sure you have the package called "ncurses"), try

    tput clear
    
    0 讨论(0)
  • Alt+F8 to clear screen and Ctrl-L to skip page

    0 讨论(0)
  • 2021-01-30 21:20

    Using shortcuts (for mitty console users)

    Alt+F8 to clear screen and Ctrl-L to skip page

    Using sh bash adding a command

    If you use console2 or same consoles, you can add this sh code as without extension this location : ..\cygwin64\bin\

    cls and /or clear (without extension)

    #!/bin/sh
    printf "\033c"
    

    Then you can use cls and|or clear in cygwin command.

    0 讨论(0)
  • 2021-01-30 21:25

    There is two ways:

    Using shortcuts

    Alt+F8 to clear screen and Ctrl-L to skip page

    Using Clear alias

    1. Go to: cygwin\home\USER\.bashrc
    2. Open .bashrc file and put this alias alias clear='printf "\033c"'.
    3. restart your cygwin terminal.
    4. to clear your screen use clear command.
    0 讨论(0)
  • 2021-01-30 21:29

    I have this in my ~/.bashrc:

    alias clear='printf "\033c"'
    

    likewise, printf "\033c" clears the screen from within a bash script.

    0 讨论(0)
提交回复
热议问题