[PYTHON] How to add Anaconda Powershell Prompt to Windows Terminal?

Synopsis

In Windows 10, it is a story to add ʻAnaconda PowerShell Prompt to Windows Terminal. I wrote this article because I found only the ones that can add ʻAnaconda Prompt by searching.

Intro

For those who use [ʻAnaconda](https://docs.conda.io/projects/conda/en/latest/glossary.html#anaconda), [Miniconda](https://docs.conda) Those who use .io / projects / conda / en / latest / glossary.html # miniconda) should also be using ʻAnaconda Prompt. Anyone who has been with Conda for a long time will want to use it in the latest environment. image.png

[ʻAnaconda Promptnow supportsPowershell](https://qiita.com/yniji/items/668f805a72a6ced6a2bd), but it was still not perfect. This is because each time Powershell is started, the environment variable % PATH% for the condacommand is set and the(base) virtual environment is ʻactivate, which is a pain of waiting time.

However, nowadays, immediately after installing ʻAnaconda or Miniconda, shortcuts are prepared in advance for ʻAnaconda PowerShell Prompt and ʻAnaconda Prompt`, which is very convenient. image.png

Under these circumstances, Windows Terminal has appeared. It's great that you can use different types of terminals as tabs in a single window. What's more, the startup time of PowerShell is shortened and it is stress-free.

You have no choice but to add ʻAnaconda Powershell Prompt`. So what should I do?

Setting method

First of all, the configuration file is like PowerShell,

$env:LocalAppData\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json

It is placed in. In the Cmd style,

%LocalAppData%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json

It is placed in.

And add the following to this json file.

{
    "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44b9}",
    "name": "Anaconda Prompt",
    "startingDirectory" : "%HOMEPATH%",
    "commandline": "%userprofile%\\Documents\\PowerShell\\conda.cmd",
    "icon": "%SystemDrive%\\tools\\miniconda3\\Menu\\Iconleak-Atrous-PSConsole.ico",
    "hidden": false
}

Details of setting items

Use New-GUID forguid It seems that the value created by However, it is troublesome, so I just copied and pasted the Powershell one and changed one character.

I think name can be anything as long as you know yourself.

You can use whatever you like for ʻicon`, but I linked to the official icon.

commandline specifies to execute the following batch file.

%userprofile%\\Documents\\PowerShell\\conda.cmd


%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\tools\miniconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\tools\miniconda3' "

The contents of this batch file are just a copy-paste of the link destination string for PowerShell from the shortcut files in C: \ ProgramData \ Microsoft \ Windows \ Start Menu \ Programs \ Anaconda3 (64-bit). ..

Looking at stackoverflow etc., " commandline is from the shortcut file of the start menu There are many things that say "copy and paste the link destination character string". But this doesn't work.

The properties of the shortcut file in C: \ ProgramData \ Microsoft \ Windows \ Start Menu \ Programs \ Anaconda3 (64-bit) are as follows, but even if you copy and paste this and specify it in commandline, the command is normal. Because it will not be received as. image.png

The part after -Command just got an error and it didn't work. That said, because how to receive Powershell arguments is too mysterious It may just not be understandable to me. Is there any way?

It was a waste of time, so I decided to write this string to a batch file and have it run.

Configuration file example

And finally, in my case, the settings were as follows.

json-doc:%LocalAppData%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json



// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation

{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",

    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles
	        "fontFace": "Cascadia Code PL",
                "useAcrylic": true,
                "acrylicOpacity": 0.7
        },
        "list":
        [
            {
                // Make changes here to the powershell.exe profile
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false
            },
            {
                // Make changes here to the cmd.exe profile
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "cmd",
                "commandline": "cmd.exe",
                "hidden": false
            },
            {
                //"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                //"hidden": false,
                //"name": "PowerShell",
                //"source": "Windows.Terminal.PowershellCore"
	        "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
	        "name": "PowerShell Core",
	        "source": "Windows.Terminal.PowershellCore",
	        "hidden": false
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "guid": "{46ca431a-3a87-5fb3-83cd-11ececc031d2}",
                "hidden": false,
                "name": "kali-linux",
                "source": "Windows.Terminal.Wsl"
            },
            {
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "hidden": false,
                "name": "Ubuntu",
                "source": "Windows.Terminal.Wsl"
            },
            {
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44b9}",
                "name": "Anaconda Prompt",
                "startingDirectory" : "%HOMEPATH%",
                "commandline": "%userprofile%\\Documents\\PowerShell\\conda.cmd",
                "icon": "%SystemDrive%\\tools\\miniconda3\\Menu\\Iconleak-Atrous-PSConsole.ico",
                "hidden": false
            }
        ]
    },

    // Add custom color schemes to this array
    "schemes": [],

    // Add any keybinding overrides to this array.
    // To unbind a default keybinding, set the command to "unbound"
    "keybindings": []
}

result

The following is the state after the settings are reflected. What do you think. image.png

reference

If you want to know more about the settings, please see Editing Windows Terminal JSON Settings. please look.

environment

The environment in this article is as follows.

In my case, I use Chocolatey to install Miniconda3 and Windows Terminal. Even if you download it directly from the official website, you can go in almost the same way.

Excelsior!

Recommended Posts

How to add Anaconda Powershell Prompt to Windows Terminal?
How to add python module to anaconda environment
Anaconda on Windows Terminal
[Python] How to install OpenCV on Anaconda [Windows]
How to install / verify graphviz on anaconda / windows10
How to install Python [Windows]
How to hack a terminal
How to run a Python file at a Windows 10 command prompt
[PowerShell] How to search for rows like Linux grep (Windows)
How to install python using anaconda
How to use Dataiku on Windows
How to update Spyder in Anaconda
How to use virtualenv with PowerShell
How to install pycrypto on Windows
How to add sudo when debugging
How to add AWS EBS volume
How to install music 21 on windows
How to install Anaconda with pyenv
Goodbye to the command prompt in WSL, VSCode and Windows Terminal
How to update to Chainer 2.0 (Windows + CUDA 8.0 + CUDNN)
[Kivy] How to install Kivy on Windows [Python]
How to use Cmder with PyCharm (Windows)
How to use Anaconda interpreter in PyCharm
How to install richzhang / colorization on Windows 10
How to install Windows Subsystem For Linux
How to make multi-boot USB (Windows 10 compatible)
How to add options to Django's manage.py runserver
How to install the deep learning framework Tensorflow 1.0 in the Anaconda environment of Windows
How to keep track of work in Powershell
Add Windows to the Linux OS boot menu
How to add arbitrary headers to response with FastAPI
MeCab: Add new words to user-defined dictionary (Windows)
How to quickly install h5py on Windows 10 [Unofficial]
How to fix when Terminal input becomes abnormal
How to measure line speed from the terminal
How to live a decent life on 2017 Windows
[ESXi (vCenter)] How to add NIC for CentOS 7.3
How to build two CentOS7 environments / Windows10 + VirtualBox + Vagrant
[Python] [Django] How to use ChoiceField and how to add options
How to add help to HDA (with Python script bonus)
How to embed mod_wsgi into Apache on Python Windows
How to share folders with Docker and Windows with tensorflow
How to instantly launch Jupyter Notebook from the terminal
How to add page numbers to PDF files (in Python)
How to resolve SSL module errors in Anaconda environment
How to exit when using Python in Terminal (Mac)
How to use jupyter lab in Windows 10 local environment
Execute Python function from Powershell (how to pass arguments)
[Morphological analysis] How to add a new dictionary to Mecab
How to add color bars in matplotlib bar plot
How to run Django on IIS on a Windows server
How to deal with Executing transaction: failed in Anaconda
How to operate Firefox with selenium on Windows Memo
Make anaconda environment available from command prompt on windows
How to delete "(base)" that appears in the terminal when Anaconda is installed on Mac