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.
Related
I connect to remote host in VSCode. Then let' say I type the following command in VSCode terminal
sh ./environment/activate_python_jupyter.sh
and then I realize that I should use the pyspark one instead of the python one, so I use up arrow to find the above command, and use left/right arrows to locate my cursor to modify thon to spark. The modified command looks like this before I hit enter
sh ./environment/activate_pyspark_jupyter.sh
However, after I hit the enter I find out that the modified command is not the one I see before (checked by up arrow), it might be something like this
sh ./environment/actispark_python_jupyter.sh
I try several times and each time the modified command looks good/turns to a different and wrong one before/after I hit enter. I finally realize that it is because the cursor was actually not located in the right place when I modified the command, although it looked good before I hit enter.
More interestingly, my cursor can go beyond the $ (dollar sign) when I use up arrow to find a command and move the cursor using the left arrow.
This looks like a cursor location bug. Have someone met with such issue and happen to know a solution?
For reasons outside of my control I'm stuck using python 2.6.6 and IPython 0.10.2. I also normally use the tcsh shell, and have gotten quite used to completing a command from the history using <A-p> (i.e. pressing the ALT key and p). However, this doesn't work in IPython. I know I can press <C-r> and then start typing a command, but what inevitably is happening is that I start a command, press <A-p>, get a colon indicating some weird state, then exit out of that state, delete my command, press <C-r> then search for my command. It's getting rather irritating. Is there any way to make <A-p> complete my already started command by relying on the history?
Ouch, this is an old version of IPython, Python (and pip). The bad news is I don't have much experience with such an old version of IPython, the good new is; it was way simpler at that time.
Most of the shortcut and feature are provided using readline, and the python bindings of stdlib. Meaning that most likely what you are trying to configure is readline itself and not only IPython; so you can find more information on that outside of IPython !
The secret is to grep in the source-code for parse_and_bind, then you'll find the following example configuration, leading me to change the ~/.ipython/ipy_user_conf.py to be like so at around line 99 (all indented an extra 4 space to be in the main() function):
import readline
readline.parse_and_bind('set completion-query-items 1000')
readline.parse_and_bind('set page-completions no')
rlopts = """\
tab: complete
"\C-l": possible-completions
set show-all-if-ambiguous on
"\C-o": tab-insert
"\M-i": " "
"\M-o": "\d\d\d\d"
"\M-I": "\d\d\d\d"
"\C-r": reverse-search-history
"\C-s": forward-search-history
"\C-p": history-search-backward
"\C-n": history-search-forward
"\e[A": history-search-backward
"\e[B": history-search-forward
"\C-k": kill-line
"\C-u": unix-line-discard"""
for cmd in rlopts.split('\n'):
readline.parse_and_bind(cmd)
The repetition of commands make me think that what \C,\M or [e mean might be system dependant. I would bet on \C being Control, and \M being Meta (Alt, Opt), but at least one of these line did the trick for me (and also now tab allows to complete). See also man readline for the list of commands you can bind to what, and enjoy! Hoping you can upgrade to Python 3 and IPython 6 at some point.
[Edit]
See Eric Carlsen second comment under this answer for how it was resolved.
I'd like to be able to run a spark-shell command via it's history number. When I type :history or :h?, I then cut and paste the command - even though the history command gives it an ID number. I'd like to be able to type
:61
or something to just rerun the command. Is there something like that?
You can press control + R, then start typing to search for your command. You can then press enter to run, or you can edit the command before running, like in readline.
Yes It is possible to use the use HISTORY command in spark shell
scala> :history
or
scala> :22
or
scala> ctrl + r
dpeacock's answer is probably the best you can get currently.
If you look at this SO question you can see that you could load the history yourself, but loading and running it is another story as I cannot seem to find a way to get access to the ILoop variable, which is the interactive loop that you could run an interpret command through.
To load the history, just do
val history = new FileHistory(new File("HOME/.spark_history"))
history.index //gives you the current number
history.moveTo(NUMBER) //moves the cursor
history.current //gives you the command you want
You could wrap this all up in an object, but without the ILoop you would still need to copy and paste. So....the short answer is not really
In Linux it will be present in
/home/<userid>/scala_history for spark-shell
Ok I'm having trouble and google isn't helping, so I thought I'd come to you geniuses. I'm using Powershell and posh-git, and it keeps doing something that I'm sure I can exit out of with a magic command, I just don't know it yet.
Basically, when I run git diff (or something else with a long result), it will only give me a screen's worth of information, and end the screen with a colon
:
And if I keep pressing Enter it will add more to the screen til it is done showing everything for that command, and shows
<END>
But now what? How do I get out of this and back to calling commands? Enter, Esc and the other things I thought to try are not helping. I'm sure this must be a simple thing, but I don't know how to explain to Google what I want.
Anyone know?
if you do a git config -l you may see some relevant entries like:
core.pager='less'
pager.diff=false
pager.log=true
You can enable or disable the pager for different commands, or set a different pager. https://www.kernel.org/pub/software/scm/git/docs/git-config.html has the details, check out the core.pager section and pager.<cmd> sections for specifics.
If you're using 'less' as your pager, hit 'h' at that : prompt to get lots of details about what you can do there, and as pointed out by others, q, Q, or ZZ will get you back to the command line.
You can terminate the current command using CTRL+C. Is that what you're asking?
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.