Lanice Sims
Lanice Sims

Reputation: 11

Git Bash (Windows) not using PATH

I'm trying to set up python as an alias on my git bash and I've edited both my .bashrc and .bash_profile to have the alias. I've edited both files and I am still getting a command not found prompt within Git Bash: bash-screenshot

.bashrc and .bash_profile:

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
# Enable tab completion
source ~/git-completion.bash
alias python="~\AppData\Local\Programs\Python\Python35\python.exe"

Anybody have any ideas?

Upvotes: 1

Views: 882

Answers (1)

Jean-François Fabre
Jean-François Fabre

Reputation: 140297

Unlike python, backslashes not escaping anything are removed in bash.

So

alias python="~\AppData\Local\Programs\Python\Python35\python.exe"

creates an alias to ~AppDataLocalProgramsPythonPython35python.exe

Fix:

alias python="~/AppData/Local/Programs/Python/Python35/python.exe"

or just set the path (.exe suffix is supported on Windows flavours of bash)

export PATH=$PATH:~/AppData/Local/Programs/Python/Python35

(so programs not having access to aliases/shell built-ins can still run python using subprocess or exec)

Upvotes: 3

Related Questions