I have written a very simple command line utility for myself. The setup consists of:
- A single .py file containing the application/source.
- A single executable (chmod +x) shell script which runs the python script.
- A line in my .bash_profile which aliases my command like so:
alias cmd='. shellscript'(So it runs in the same terminal context.)
So effectively I can type cmd to run it, and everything works great.
My question is, how can I distribute this to others? Obviously I could just write out these instructions with my code and be done with it, but is there a faster way? I've occasionally seen those one-liners that you paste into your console to install something. How would I do that? I seem to recall them involving curl and piping to sh but I can't remember.
cds to different directories, but callingos.system('cd /my/path')doesn't work since that's a sub-shell (from what I understand). So basically my Python script writes the jump path to a temp file and the shell script reads it and does the change.os.chdir()will change the current working directory of your running script.os.chdir()won't quite get the job done, since it will change the directory in the subshell that the python script is running in, not in the shell the user is using. That's why sourcing the shell script is needed.