4

Is there a way to create aliases for WSL Bash on Windows 10?

With Git Bash, it's easy: edit the file .bashrc: alias alias-name="command" I've done my research, including these posts 1, 2 but couldn't find the answer.

If that's not possible. Is it possible to set Git Bash as an integrated terminal in Visual Studio Code?

Viet
  • 6,513
  • 12
  • 42
  • 74
  • The post you linked as #1 was from someone who actually did this right, except for having Windows newlines in their file. With that one exception, it was working for them, and following the same practice (and being sure to use Linux-native tools to edit the file) would work for you. – Charles Duffy Oct 08 '17 at 04:09
  • 2
    ...that said, aliases in general are fairly fragile -- they only work in interactive shells, and have very little capability (can't do conditional logic, can't reorder arguments, etc). Usually, a function or an executable script is a better tool for the job. – Charles Duffy Oct 08 '17 at 04:12
  • @ Charles Duffy thank you so much! i'll definitely look into it. – Viet Oct 08 '17 at 13:52

1 Answers1

11

I got tripped up on this because I edited the wrong .bashrc file. There is one in the linux file system (home/robin/.bashrc) and there's another one in the windows file system (c:/users/robin/.bashrc). I had to edit the one in the linux file system. Now when I launch Windows Terminal I can use my aliases.

Robin Nelson
  • 494
  • 7
  • 14