4

Certain conda commands are long, eg. "jupyter notebook" or "conda activate/deactivate", and conda does not support tab completion on Windows (based on my searches). Is there any way to set alias for them on Windows to save some keystrokes?

  • for jupyter notebook I tried DOSKEY jupyter=jupyter-notebook $* (after declaring path to the .exe file in PATH) but got error that conda failed to create process.
  • also found out that there is no such cmd like "conda alias" to define aliases.
Victor Luu
  • 244
  • 2
  • 10
  • 1
    just found a solution for this, still can define aliases for conda via DOSKEY, but the aliases only work inside anaconda prompt. So put `DOSKEY jupyter=jupyter-notebook $*` and other aliases in sth like alias.cmd and run the file inside conda prompt. Then aliases work magically :) – Victor Luu Jun 29 '20 at 00:04
  • You can post your solution as answer with extra details – Jan Černý Jun 29 '20 at 00:07
  • 1
    for more details on how to define alias in windows and source the alias file auto each time cmd is launched, see this [nice post](https://stackoverflow.com/questions/20530996/aliases-in-windows-command-prompt). – Victor Luu Jun 29 '20 at 00:08

2 Answers2

2

I just found a solution for this, it turns out that we still can define aliases for conda via DOSKEY, but the aliases only work inside anaconda prompt :).

So put DOSKEY jupyter=jupyter-notebook $* and other aliases in sth like alias.cmd and run the file inside conda prompt. Then aliases work magically :). Just wonder if there is some better way to do this.

Also, for more details on how to define alias in windows and source the alias file auto each time cmd is launched, see this nice post.

Victor Luu
  • 244
  • 2
  • 10
0

You can find a solution at How to Launch Jupyter Notebook Quickly to this problem that does not depend on DOSKEY.

The solution article gives two solutions and I prefer the second one. To open Jupyter Notebook I just do the following in the Anacanda Powershell

cdjn # change directory
jn # alias for 'jupyter notebook'

Here is my config file Microsoft.PowerShell_profile.ps1.

function Chdir-Workspace
{ & cd '~\Workspace' }
New-Alias -Name cdjn -Value Chdir-Workspace

function Start-JupyterNotebook
{ & jupyter notebook }
New-Alias -Name jn -Value Start-JupyterNotebook

The article encourages to install Windows Terminal in advance, which I did not follow.