Open maxheld83 opened 5 years ago
so the idea here would be that currently, you can only run these scripts by providing the path to them, like so: bash foo/bar/zap.sh
(or whatever).
That can be a bit cumbersome.
(It's easy enough to get rid of the bash part if the scripts have a shebang line and chmod + x
has marked them executable; pretty sure I already did that but I could be wrong).
For other CLI tools, we can usually just call, say pandoc
and be done with it (and not the path where pandoc, the executable sits).
For that to work, pandoc
has to be on your PATH
(that's a special environment variable which consists of a list of directories along which your computer will look for executables).
So if we want our custom scripts here to work, we need to put them on the PATH
somehow.
We can either do that by:
PATH
PATH
list. (That's what the .bashrc
approaches do like here https://unix.stackexchange.com/questions/29791/bash-profile-not-sourced-when-running-su/29811#29811).I think 1 might make more sense because messing with peoples .bashrc
can cause all sorts of problems.
The question is then how we do that; one way might be to look at existing ways to distribute binaries (homebrew), or to tap into the R infrastructure for executibles (it comes with a couple of them). I don't know what the right way to go about this here, this would probably need some research.
A starting point might be the https://cran.r-project.org/package=littler package, which must presumably achieve something similar for its R-based custom command line tools. See whatever that tool is doing and try to copy that.
However, all of this is fairly advanced/intermediate "linux-"fu, and might be a bit overwhelming. If you want to delve into this, I would recommend studying https://linuxjourney.com.
https://unix.stackexchange.com/questions/63665/how-to-define-a-bash-function-that-can-be-used-by-different-scripts this could do it right? We could try to export the function into a globally available script and make the user execute it? Trying really hard to understand things here and hope I can at least provide some insights with my findings. =)