Clear a terminal screen for real

前端 未结 11 1443
悲哀的现实
悲哀的现实 2020-11-30 15:48

Using the clear command on the terminal only fools the user into thinking the screen has been cleared...you can still see output from the previous commands when

相关标签:
11条回答
  • 2020-11-30 16:35

    Try reset. It clears up the terminal screen but the previous commands can be accessed through arrow or whichever key binding you have.

    0 讨论(0)
  • 2020-11-30 16:36

    The following link will explain how to make that alias permanent so you don't have to keep typing it in.

    https://askubuntu.com/questions/17536/how-do-i-create-a-permanent-bash-alias

    These are the steps detailed at that link.

    1. vim ~/.bashrc or gedit ~/.bashrc or what ever text editor you like
    2. put alias cls='printf "\033c"' at the bottom of the file
    3. save and exit
    4. . ~/.bashrc (and yes there should be a space between . and ~)
    5. now check to see if everything worked!

    I take no credit for this information just passing it along.

    0 讨论(0)
  • 2020-11-30 16:38

    None of the answers I read worked in PuTTY, so I found a comment on this article:

    In the settings for your connection, under "Window->Behavior" you'll find a setting "System Menu Appears on ALT alone". Then CTRL+L,ALT,l (that's a lower case L) will scroll the screen and then clear the scrollback buffer.

    (relevant to the OP because I am connecting to an Ubuntu server, but also apparently relevant no matter what your server is running.)

    0 讨论(0)
  • 2020-11-30 16:42
    echo -e "\e[3J"
    

    This works in Linux Machines

    0 讨论(0)
  • 2020-11-30 16:44

    Compile this app.

    #include <iostream>
    #include <cstring>
    
    int main()
    {
      char str[1000];
      memset(str, '\n', 999);
      str[999] = 0;
      std::cout << str << std::endl;
      return 0;
    }
    
    0 讨论(0)
提交回复
热议问题