How to exit gitbash after running Mongod? - mongodb

I am following some tutorials on how to work with Mongodb but they don't explain how to close the CLI. I usually just use "exit" but after running mongod it now does nothing, and if I try to leave by just closing the window I get a message saying "processes running in session".
I get the same problem with the other gitbash window after running npm run dev (I think the "dev" part is just specific to what I do now?).

Normally you can press 'ctrl' + 'c' on your keyboard and it should stop the process running on your command line tool.
Have a look here thing might be more MongoDB specific help
https://stackoverflow.com/a/11776728/4389143

The command to save a file in Vim and quit the editor is :wq . To save the file and exit the editor simultaneously, press Esc to switch to normal mode, type :wq and hit Enter .
Check this.

Related

Neovim: how to send keys to terminal emulator

When I open up a nvim terminal emulator and enter the following command, trying to execute command 'python':
:normal! ipython
It turned out the register content is pasted onto the screen, as if 'p' is pressed under normal mode, even if 'i' has been pressed in prior to (supposedly) enter terminal-insert mode.
This does not help either:
:execute "normal! ipython\<CR>"
Where have I gone wrong, and how could I do it correctly?
Alternatively I used termopen() to execute a command in the terminal on start, something like
:call termopen('python')
But still, no idea about how to do so with normal!.
:normal! ipython
doesn't mean "run the program". It means "switch to Normal mode and run !" which is a filter command; then run i that is switch to Insert mode and insert "python".
To run a command from the vim command line use
:!ipython

How to exit Command Prompt after launching VSCode

Here are the steps to reproduce the problem:
Open Command Prompt. ( cmd )
Run code . to launching VSCode.
Type exit and hit Enter in the Command Prompt.
Then the Command Prompt is just paused. I have to wait VSCode exit to let Command Prompt window closed.
Does anyone know why? How can I close Command Prompt window without exiting VSCode?
I found a solution here: https://github.com/Microsoft/vscode/issues/6608. It involves changing the code.cmd file (usually found under "C:\Users\yourUsername\AppData\Local\Programs\Microsoft VS Code\bin").
Changing the fifth line in that file from
call "%~dp0..\Code.exe" "%~dp0..\resources\app\out\cli.js" %*
to
start "" "%~dp0..\Code.exe" "%~dp0..\resources\app\out\cli.js" %*
will make the cmd window close right away. But that change will apparently break some other things (specifically the --wait flag), so I figure it's wiser to leave the code.cmd file alone.
Instead I made a copy ("codeNoCommandPrompt.cmd") right beside it and changed the line in there. That works fine for my usecase, namely having VS Code start on a specific folder alongside a bunch of other programms via a script.
I just tested it (using the latest VSCode 1.24.1), and it does work: the CMD shell session closes immediately when typing "exit".
Try calling the code.cmd script with its full path to see if the issue persists:
"C:\Program Files\Microsoft VS Code\bin\code.cmd" .
Try also the same command after having simplified the PATH (for testing)
set PATH=C:\Program Files\Microsoft VS Code\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
code .
Simply use this
code . && exit
Check your PATH variable, maybe you have duplicate entries for VS Code
Go System Properties -> Envieronment variables -> select PATH variable then click Edit.
Remove "C:**\Microsoft VS Code".
Leave intact "C:**\Microsoft VS Code\bin"
This happens when you reinstall vscode with "add to PATH" checked

Ctrl+c not working in integrated terminal which uses Powershell

I'm using Powershell in the integrated terminal by adding the following line to the settings.json file.
"terminal.integrated.shell.windows": "C:\\WINDOWS\\system32\\WindowsPowershell\\v1.0\\powershell.exe",
It works very well, but usually, when I'm in Powershell, typing ctrl+c cancels what I had typed and opens a new line.
But in the integrated terminal it just prints ^C.
Is there a way to fix it or find an alternative method to achieve this?
Thanks
This is with VSCode and not necessarily with the PowerShell Extension. You can see this by just using the default cmd.exe terminal, CTRL+C does nothing. It does not print the ^C at all, and creates no new line.
If you want this to work as expected in the normal command prompt or PowerShell.exe you will need to submit an issue to VSCode repository and request it.
I would expect this is all tied to the keybindings.json file. I went through that file but could not find a command available to the same function that occurs in the full command prompt or console. So this will likely need a new command added for VSCode.
If you search through the keybindings file you can see the terminal has that key CTRL+C bound to copySelection when terminalFocus && terminalTextSelected. This is why the ^C is being output, and no new line is being added.
A workaround:
Pressing Esc will erase the line back to the beginning.

MongoDB shell is not maintaining command history

In my MongoDB shell the command history is lost the moment I come out of it. How to configure it to remember the commands?
I don't know what's the theory behind it, but from my experience:
if you quit the command line with Ctrl+C or exit command, history is kept;
if you quit by closing the command line window (red cross on Windows 7), or with quit() command, history is not kept, but the previous history of properly closed windows is not erased.
That's not really "configuration" but it works for me (Windows - mongo 2.6.1).
History file should be in ~/.dbshell

Ho to abort a command in Ubuntu(16.04), where CTRL+C I am already using for copying?

I am currently using CTRL+C and CTRL+V for copy and paste respectively in Ubuntu (16.04). So in this case, how can I terminate /abort a command in Terminal.
NOTE: The control+C does not work for me neither quit() or Exit().
Please advise.
The default terminal (gnome-terminal) uses Ctrl+Shift+c and Ctrl+Shift+v for exactly this reason. If you are in a bash prompt (unclear from context here), you can quit by writing exit.