History of 2022-10-29 A bash helper for prefixed scripts

2022-10-29
10:16 UTC Revision 1 . . . . mborkLet’s say we have some project we are working on. The project involves a number of shell scripts for various tasks, like versioning, building, testing, deploying etc. It is useful to have these scripts in your $PATH while working on that project. There are several ways to do that. One way is to add the directory containing them to $PATH, but only for the time we’re working on the project. Another is to use things like npm run and the scripts property of package.json (and I’m fairly sure many other languages feature similar facilities). Recently, I found yet another one, which is pretty useful and extremely cool at the same time. I prefixed all the scripts with the project’s (abbreviated) name, say dw-​. So, assume I have scripts like dw-version.sh, dw-build.sh, dw-test.sh etc. Now I can permanently add the directory containing them to my $PATH, since I (kind of) namespaced them and they won’t get mixed with any other project’s scripts (nor general use utilities). The only trouble that’s left is that typing dw- each time is a bit tedious. Well, Bash to the rescue.