Integrate mongo shell [mongosh] in Windows Terminal | Easy
I like Windows Terminal a lot, especially its customization features. By changing its settings.json file one can customize the terminal according to one's taste.
Earlier; to connect mongo shell i.e. mongosh with a MongoDB instance one had to to type the command mongosh "mongodb://<username:password>@<mongodb-instance>/<database-name>"
in CMD
or Powershell
.
![](https://blog.anurut.com/content/images/2020/08/mongosh-cmd-1.jpg)
For this command to work you need to add mongosh.exe
to path variable in Windows. You can find an article here which goes in detail how to do that.
To integrate mongosh with Windows Terminal
Step1: Open Windows Terminal
Type 'windows terminal' in the search bar located in the Windows taskbar and click on Windows Terminal option.
![](https://blog.anurut.com/content/images/2020/08/open-windows-terminal.jpg)
Step 2: Open settings.json
![](https://blog.anurut.com/content/images/2020/08/open-settings.png)
Open settings.json by clicking on the down arrow besides the +
tab and clicking on settings
. Alternatively, you can use Ctrl + ,
keyboard shortcut as well.
Step3: Edit settings
![](https://blog.anurut.com/content/images/2020/08/settings.jpg)
I have bound json files to open with Visual Studio Code you can use any text editor. Now copy the powershell
profile and paste it below it, as shown below.
![](https://blog.anurut.com/content/images/2020/08/copy-paste.jpg)
And change it like this (or you can copy it as it is from below and paste it in your file):
![](https://blog.anurut.com/content/images/2020/08/editied-profile.jpg)
Save and see the changes.
![](https://blog.anurut.com/content/images/2020/08/open-mongo-shell.jpg)
Now whenever you want to open the mongo shell:
Open Windows terminal > click on the drop down > click on Mongo Shell and you have a connected shell. No need to remember the connection string and no hassle to type it again and again.
![](https://blog.anurut.com/content/images/2020/08/working-mongo-shell.jpg)
If you have multiple mongo instances running, you can replicate the steps above and have multiple quick connect tabs available in the Windows terminal.
Hope this article is of any help. Thanks for reading.