2

I have the following line in my .bashrc (WSL Ubuntu):

alias code="code-insiders"

I'm able to run code . from an ubuntu.exe terminal, but when I run wsl code . in cmd.exe, I get the following error:

/bin/bash: code: command not found

Is there a way for me to use alias-generated commands with wsl from cmd.exe?

Thanks!

2
  • No, you'll need to use a function instead of an alias.
    – AFH
    Commented Jun 4, 2019 at 11:14
  • Try the same in .profile or .bash_profile file. Or run bash --login. You will get the idea.
    – Biswapriyo
    Commented Jun 4, 2019 at 11:54

1 Answer 1

3

Based on @Biswapriyo's recommendation, I was able to get my ~/.bashrc to run (And my aliases to show up) by running bash -ic <cmd> instead of wsl <cmd> e.g.:

bash -ic code .

However, since bash.exe is deprecated, it's probably better to run

wsl bash -ic code .

Although, that starts to get a bit less convenient.

1
  • for zsh, you can use wsl.exe zsh -ic ${your alias}.
    – X.Arthur
    Commented Apr 30, 2021 at 14:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .