user1015104
user1015104

Reputation:

How to clear console in MongoDB

While using Mongodb console or shell sometimes my screen is cluttered with a lot of previous output which I do not need. So, is there a function to clear console in MongoDB?

Something like an analog of clear in MatLab.

I have tried clc, clear but with no success.

Upvotes: 85

Views: 42108

Answers (3)

shaifan shaikh
shaifan shaikh

Reputation: 1

Ways to clear the mongoDB shell screen :

  • using cls command
  • using a keyboard shortcut ctrl + L
  • using console.clear() method

you can use any of this method to clear mongoDB shell screen.

Although you can run your previous commands or queries by using up/down keyboard keys.

reference

Upvotes: 0

Salvador Dali
Salvador Dali

Reputation: 222531

Judging by Jira they have done it: You need to write cls in the shell.

You can also use a hotkey: CTRL + L.

In macOS: Command + K.

Check more hotkeys for the shell here.

Upvotes: 158

Stennie
Stennie

Reputation: 65323

If you are using MongoDB 2.0 or higher, the mongo shell supports both:

  • cls command
  • Ctrl+l (clear screen)

Note that both of these clear the screen and put the cursor at the top .. but you can still scrollback to see previous history.

In OS X Terminal.app you can also do:

  • Command+K (clear scrollback)

Clearing the screen and/or scrollback buffer are independent of the history, so you can still cursor up/down to run previous commands.

Upvotes: 70

Related Questions