Sorry, going on a wee trip sideways. But felt this addition/change to my development environment deserved a mention. It has the potential to positively affect how you work in a Windows’ environment.

The Command Line

Working with git, hugo, conda and the like is pretty much done from the command line, i.e. in a terminal window. There are GUIs available for Git, but… In the distant past, Windows users really only had the cmd prompt, aka a dos box. Then along came PowerShell, which I never really tried out. For my purposes the basic command prompt worked just fine.

But with this and a couple of other projects/courses I have been working on, I was opening multiple command prompts. One for git, one for hugo, perhaps one for conda. In the case of this project, I actually have two command prompts open for git — one for the blog content and one for my python play area.

Kinda messy. Especially since I also have two VS Code windows open — one for the blog content workspace and one for project coding workspace. Then I heard about the new Windows Terminal app. Well, new to me.

Windows Terminal

Quoting the Microsoft web site,

Windows Terminal is a modern terminal application for users of command-line tools and shells like Command Prompt, PowerShell, and Windows Subsystem for Linux (WSL). Its main features include multiple tabs, …

That multiple tabs is what got me interested. Won’t get rid of my two VS Code windows, but might help clean up the screen real estate a little.

So off I went to the Microsoft Store. And, installed the app.

Out of the box the terminal app provides CLIs for the cmd prompt, PowerShell and the Azure Cloud Shell. So far, I have not had any use for the latter.

And though I use the default PowerShell tab, I still just mostly use old cmd prompt commands. May eventually get into the additional capabilities of PowerShell, but for now I will make do with what little I know.

However, I did want to be able to open a conda cli. I.E. an Anaconda shell. Would be nice if I could do so in Windows Terminal, without having to use the Ananconda menu to do so. Well that meant I had to add another shell to the Windows Terminal settings.json file.

Adding an Anaconda Shell to Windows Terminal

My primary source for how to do this was Easily add Anaconda Prompt to Windows Terminal.

Default App for .json

But, I had a bit of a problem getting the settings file to open in VS Code. Kept wanting to use Notepad. Turns out I didn’t have a default app set for json files. Which meant Windows defaulted to the only text editor it knew about. So off to Windows Settings I go.

In the Settings window, clicked on Apps. In the menu on the left, clicked on Default apps. Then scrolled down and clicked on Choose default apps by file type. It takes a few seconds to load everything up. Clicked Choose a default, and selected VS Code.

Now, when I open a terminal window, select the “down pointer” (⌵) and click on Settings, the terminal app settings.json file opens in VS Code. An open window if I have one, or launches VS Code if I don’t.

Modifying settings.json

In that file there is an entry\dictionary variable labelled "profiles". And, with in it an entry/dictionary variable labelled "list". list is an array of shell profiles. I added my anaconda shell to this list.

I started by copying the entry for the command prompt shell below itself. I.E. the settings for the anaconda shell will be just below those for the command prompt and above those for azure shell.

Then I made the following changes:

  "name": "Anaconda Prompt",
  "commandline": "cmd.exe /K E:\\appDev\\Miniconda3\\Scripts\\activate.bat",

You may wonder how I got the details for the “commandline” value. I selected Anaconda (64-bit) from the start menu. Note your name may differ. Then I right clicked Anaconda Prompt (Miniconda3) (your name may again be different), hovered over More, then selected Open file location. That opened a file explorer window in which the was a number of shortcut files. I right clicked the shortcut for Anaconda Prompt (Miniconda3) and selected Properties. I then selected the contents of the Target field and copied/pasted it at the appropriate spot in the settings file.

That now looked something like:

  "commandline": %windir%\System32\cmd.exe "/K" E:\appDev\Miniconda3\Scripts\activate.bat E:\appDev\Miniconda3

We really only want to run activate.bat in a command prompt and keep it open (the /K bit). So I edited the command to remove everything else. And since string values in JSON format need to be quoted, I removed the quotes around the /K, and added them around the whole command line string.

Next I dealt with the GUID value. I didn’t just want to make some changes to the existing one. So I decided to let Windows help me out. Since I had Powershell open, I used the command '{'+[guid]::NewGuid().ToString()+'}' and had it generate the GUID for me. As in:

PS R:\learn\py_play> '{'+[guid]::NewGuid().ToString()+'}'
{6ce8d80e-b55a-4655-9739-4ccb9c452bde}

I then copied and pasted the new GUID, with the braces, over the previous value.

Just about done. In the article I mentioned above they added an icon for the Anaconda shell. So, I did the same. If you go to the location of your Miniconda3 installation (in my case E:\appDev\Miniconda3\) you will find a folder Menu. And in that folder you will find some icon files (.ico). In my case, I went with:

  "icon": "E:\\appDev\\Miniconda3\\Menu\\Iconleak-Atrous-Console.ico",

My complete settings.json entry for the Anaconda Prompt looks like this:

  {
      // Make changes here to the anaconda profile.
      "guid": "{6ce8d80e-b55a-4655-9739-4ccb9c452bde}",
      "name": "Anaconda Prompt",
      "commandline": "cmd.exe /K E:\\appDev\\Miniconda3\\Scripts\\activate.bat",
      "icon": "E:\\appDev\\Miniconda3\\Menu\\Iconleak-Atrous-Console.ico",
      "hidden": false
  },

Test Anaconda Shell Addition

Once done, I saved the settings.json file and tested my addition. I was able to select Anaconda Prompt from the drop down menu and it opened in a new tab. Note the keystroke ‘shortcuts’ to open new tabs with the shell you want. I then, in the Anaconda shell, entered conda -V. It returned the current version of my Miniconda3 installation. Perfect.

If you think that would also work in at a Powershell prompt, give it a try. Because of the way I installed Miniconda, it is not in my path environment variable. So, when I try to run conda -V at a PowerShell prompt, it fails.

And that’s it for this one. I really like the use of a tabbed interface allowing me to have multiple shells open in a single window. And, I expect I will eventually begin to learn something about PowerShell. But it is not currently high on my priority list. So, I mostly use the PowerShell prompt as a glorified cmd prompt.

Hopefully Windows Terminal will be of use to you as well.