I have a specific situation when I need to create an alias when “sh /usr/bin/python” must work as sh python. It is not for me; it is for the Docker container.I read many instructions form the net, like https://superuser.com/questions/105375/how-to-use-spaces-in-a-bash-alias-name, but not found resolution.
Isn’t it as easy as wrapping your command in quotes. For example, from my aliases alias yy='yay -Pw && eos-update --aur'
May I ask in which context you’ll need that alias to execute a specific python binary within the VM ? Doesn’t creating (and/or sourcing ) a venv could address the same outcome ?
docker
Try creating a function instead:
sh() {
if [[ $@ == "/usr/bin/python" ]]; then
command sh python
else
command sh "$@"
fi
}
I don’t know if that’ll work, but it might.
add it to zshrc?
Yeah, that would work. I keep my aliases anf functions in a sepreate file call .zsh_aliases which I source in .zshrc.
sourry, but how source file in zshrc?
source .zsh_aliases
What file are you passing to python. Is it a text or binary file? You can read a text file in a text editor, whereas a binary file looks like gibberish.
text, it is app.py
what wrong in my picture?
I’m wondering, fi you are trying to run a specific python version, would it not be better to set a venv
it work with docker containers?
Do you want it to run on the container or locally and start the container. I’m sure that with a bit of poking round with docker you could set up a venv on it. I’m afraid I’m not going to be much help with that as I barely use docker.
After a bit of reasearch, it suggests pythin may not be runnable like that, You need to open up sh before you run python, which makes sense now that I think about it.
Create a script file with the following contents:
/path/to/your/python/install/python
and start sh like:
sh path/to/script.sh
for now this question is closed, thank you for now

