Reputation: 889
New Windows Terminal (Windows Terminal (Preview) Version: 0.2.1831.0) have settings in JSON file. How can I setup powershell running with Anaconda? Anaconda running in powershell with:
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\Users\akali\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\akali\Anaconda3' "
Windows Terminal use profiles in JSON like this:
"profiles": [{
"colorScheme": "Solarized Light",
"commandline": "powershell.exe"
}]
How can I use running with Args with double quote in JSON that allow me run something like -Command "& 'C:\'"
?
Upvotes: 5
Views: 7602
Reputation: 329
I realize I'm late of some years but I had a similar problem and stranded up here looking for an answer. So, I'm hoping that this is useful for people like me in the future.
After some time tinkering I generated an Anaconda profile:
target
field and paste it on the field commandline
(make sure the field is commandline
and not source
)\
characters (\
--> \\
)You should have something like this
{
"guid": "{generated guid}",
"hidden": false,
"name": "Anaconda",
"commandline": "powershell.exe -ExecutionPolicy ByPass -NoExit -Command & 'C:\\ProgramData\\Miniconda3\\shell\\condabin\\conda-hook.ps1' ; conda activate 'C:\\ProgramData\\Miniconda3'"
},
As a nice sidenote, you can also create a profile to directly launch an Ipython session or a jupyter notebook.
As you may have noticed, lo launch anaconda in the commandline
field we are just launching powershell.exe
, and then telling the powershell instance to execute a -Command
, which is the subsequent string.
Were you to add a ; ipython
to the command, you would launch an ipython session.
Upvotes: 11
Reputation: 41
Right click properties of conda powershell shortcut (in desktop or start menu). There you get the path to the command that effectively starts conda using powershell.
Now, just follow the recipe of Marco Necci outlined above, just caring to put double backslashes instead of single ones.
Searching further modifications, in this site i've found that i could generate the new needed guid with powershell itself: [guid]::NewGuid()
.
And in the repo of new terminal, i've discovered it's possible to customize the icon too. My icon was in a different path, that i came across looking in anaconda shortcut in windows menu (i used anaconda navigator's icon - right click it > more > open; somewhere ending with 'Start Menu\Programs\Anaconda3 (64-bit)': right click once more in the shortcut > properties; change icon - there is the path to the icon).
Again, be wary to use double backslashes instead of single ones.
Upvotes: 1
Reputation: 8961
Building upon Navaneeth M et al, I contribute a command line which includes the default Anaconda location using USERPROFILE environment variable, specifying non-default Anaconda env (fastai), starting directory and color scheme.
"commandline": "%windir%\\System32\\cmd.exe /K %USERPROFILE%\\Anaconda3\\Scripts\\activate.bat fastai",
"colorscheme": "Solarized Light",
"startingDirectory": "c:\\sw",
Pro Tip: Use keybindings
to add a hotkey which opens a new tab in the specified project directory. For example, use ctrl-b to open a new Anaconda tab in just the right place.
"keybindings": [
{
"keys": [ "ctrl+b" ],
"command": {
"action": "newTab",
"profile": "Anaconda",
"startingDirectory": "c:\\sw\\myproject\\myprojectdirectory"
}
}
]
Upvotes: 2
Reputation: 21
Copy-paste the settings for cmd from above.
Go to "C:\Users\Username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)"
Right-click on "Anaconda Prompt (Anaconda3)"
Copy the content from the target field and paste it on the field commandline
Mine is %windir%\System32\cmd.exe "/K" C:\bin\Anaconda3\Scripts\activate.bat C:\bin\Anaconda3
Replace \ with \
Thanks to the above answer by Marco Necci, this is a more clear version with cmd and anaconda
"commandline" : "%windir%\\System32\\cmd.exe /K C:\\bin\\Anaconda3\\Scripts\\activate.bat C:\\bin\\Anaconda3"
Upvotes: 2