0

I am on Windows and using GitBash to run shell scripts in bash that run python scripts.

How can I create a project-specific alias to define a specific python environment and run shell scripts through GitBash that use that environment?

This is a file called test.sh:

# misc notes at top, like a docstring
print("Hello")
# real file will instead say myPyScript.py etc.

I can successfully run this in GitBash with C:/users/name/mypath/python.exe test.sh and it returns "Hello" to the console.

Problem: I want to use a project-specific python environment whose path is defined with an alias.

Here's what I am trying, based on Why doesn't my Bash script recognize aliases?, and how it is failing:

This is a file called .pyalias:

alias mypython='C:/users/name/mypath/python.exe test.sh'

This is a file called main_run_all.sh:

#!/bin/bash

# misc notes at top, like a docstring

shopt -s expand_aliases
source /.pyalias

mypython test.sh
# real file will instead say myPyScript.py etc

When I run sh main_run_all.sh I get test.sh: line 6: source: .pyalias: file not found

Here is the directory setup:

enter image description here

1 Answer 1

0

The format of this line:

source /.pyalias

should be:

source ./.pyalias

You must log in to answer this question.

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