How to clear console in MongoDB - 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.

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.

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.

Related

Go to previous command without scrolling through multiline commands in iPython

I have the current newest version of iPython (7.6.1) and when I try to use the up-arrow keys to get to previous commands, when I hit a multiline command, the up-arrow instead slowly goes up through each line instead of going to the previous command. To get to the command before the multiline command, I have to scroll all the way up to the top of the multiline command before I can get to the previous command. Is there another shortcut I can use to skip the multiline command and get the previous one?
At least on a Linux machine, PgUp/PgDn appears to do the trick.
If search for a particular item, partial entry followed by up/dn is nice. For example to find a previous function definition I might do
def^p
The ? help also suggests Ctrl + R for a history search. I haven't used that.
The ipython shortcuts section refers to me to prompt_toolkit, but that gives info on setting things up, not on current options.
In Macbook, you can use:
Fn + Shift + ↑ to go up
Fn + Shift + ↓ to do down

Clear history in Mongo shell

I would like to clear my history in the Mongo shell (OSX/Terminal). I have tried the command 'cls' and it clears the text in the terminal. However, when I run my next query all of which I cleared reappears along with the new information from the query. How can I prevent the history from reappearing?
This question is not a possible duplicate because the answer was to use CMD+K in the mongo shell as mentioned by the accepted answer below. The suggested duplicate was unrelated.
I think this is what you are looking for How to really clear the terminal.
reset command will do the job.
Or you can try command + K button to clear scrollback buffer in OS X as mentioned here.

Configure pointer focus properties of Matlab's command window

I'm running Matlab 2013a, under Linux, using Xmonad (using the XMonad.Config.Xfce package).
This problem occurs whether the command window is docked or not.
The command window prompt does not get the keyboard focus unless the pointer is located
over the command window.
Is there a way to get the Matlab command window to have focus behaviour just like other normal windows, like a terminal?
Most important: I'd like to have the keyboard focus follow the window focus,
and not require any special positioning of the pointer, so that I can just "Alt-Tab" around my windows and have the command window get the keyboard focus. All of the resources I've found so far relate to programmatic control of focus; I'm just trying to improve my user experience in an interactive session.
To get keyboard focus on the Command Window, include the following in your xmonad.hs
import XMonad.Hooks.SetWMName
import XMonad.Hooks.ManageHelpers
and configure your ManageHook as follows
myManageHook = composeAll . concat $
[ [appName =? a --> doCenterFloat | a <- myFloatAS ]
, (your other hooks)
] where
myFloatAS = ["MATLAB"]
Finally, include setWMName "LG3D" in your startupHook. See here for a full xmonad.hs configuration which uses this (this is where I found the solution). If you have other Java apps that don't get focus as they should you can add them to the myFloatAS list.
It's a problem in the built-in java.
If i run:
export MATLAB_JAVA=/usr/lib/jvm/java-7-openjdk/jre
matlab -desktop
Matlab works as expected.
I ran into this problem, running MATLAB2014a. I set up setWMName "LG3D" but still i couldn't get focus on my window. I had to click on the focused window to get the cursor, and sometimes the situation was even worse and I had to click on random places till i get my cursor back. This wouldn't happen on MATLAB2010. What worked for me was to use the native version of java as describe above.
In the end, i used the following bash script to start matlab8:
#!/bin/bash
export MATLAB_JAVA=/usr/lib/jvm/java-7-openjdk-amd64/jre/
/usr/local/bin/matlab8 -desktop -nosplash

Would it be possible to jump between prev/next Terminal command prompts?

I'm using zsh in OS X Terminal.app and for quite a while, I've been longing for a way to jump back and forth between prev/next prompts in the terminal's output.
One convenience with this would be to be able to review (and track errors at) the end of each command's output; eg. when you building stuff from source with ./configure; make; make install. Note: I'm obviously not referring to jumping back and forth in the command-history, but for a way to take a peek at the endings of each command's output.
Has anyone heard of such functionality in the *nix (preferrably also Mac) world? Would it require some sort of OS-centric Terminal plugin, or can it be programmatically done via a shell script which can be tied to a keyboard shortcut? Maybe I'm the only one thinking about this? :)
Edit: Here's an example scenario: Let's say I want to compile and install some program (using standard ./configure && make && make install procedure) and after the make command, I run into some errors. Now, the way I understand it (I may be completely wrong), the crucial error causing the make command to fail usually shows up in the last line(s) in the output, no? Anyway, at this point, I might do something like cat INSTALL to read up on the INSTALL document to check whether there's something I've missed. NOW, if I want to go back to see what the error was, that caused my initial make command to fail, I then have to manually scroll up to that position again, since my cat INSTALL command printed a ton of text after it.
I don't know if this scenario is the most elucidative – but there are many other situations where I wish I could just "jump" back to previous prompt lines and check up on previous command output; whether it was a simple ls command, make, git status, or whatever it was – swapping positions in the window by means of using prompt lines as "bookmark" positions seems an interesting idea to me.
command + left or right goes between tabs in iterm. is this what you are asking?
Emacs has a shell-mode that runs a shell inside the Emacs editor, providing a rich environment of additional commands for navigating and working with shell commands. This includes commands for going to the previous/next prompt, and deleting the output from commands so you can "clean up" and issue another command.
If you aren't familiar with Emacs: to start a shell inside Emacs, run emacs from the shell, then type Esc-x (or Meta-x, if you have "Use option as meta key" enabled in Terminal > Preferences > Settings > [profile] > Keyboard). This will ask for a command to execute. Enter shell.
To see a list of commands you can use in Shell Mode, enter Control-h m. Here are the ones for moving the cursor to the previous/next prompt:
C-c C-n comint-next-prompt
C-c C-p comint-previous-prompt
These commands would also be useful:
C-c C-r comint-show-output
C-c C-o comint-delete-output

How to set the mouse position under X11 (linux desktop)?

I'm wondering how to set the mouse cursor position under X11? Is it possible at all and if, where do I have to look for appropriate functions? X window system, KDE/Gnome/...?
Sounds like you're using X, so what you probably want is XWarpPointer. To give an absolute position on the whole screen, use the Root Window as dest window.
(You can get a quick and dirty list of X functions using ls /usr/share/man/man3/ | grep '^X')
I know the question is old, but I just discovered xdotool and it seems great:
http://www.semicomplete.com/projects/xdotool/
Try using xte command (part of xautomation package). Details here
If you are doing it in an xterm, the Xterm understands ANSI control codes. There is a list of these codes here.
To do from a shell script, use the xwit commandline tool.