#!/usr/bin/env bash
set -eo pipefail
function hey {
echo "Hey!"
}
TIMEFORMAT=$'\nTask completed in %3lR'
time "${@}"
Now after running a `chmod +x hey` can run it with: ./run heyFeel free to replace "time" with "eval" too if you don't want your command timed.
This is a really useful pattern because it means you can create a "run" script with a bunch of sub-commands (private or public), auto-render help menus and create project specific scripts without any boilerplate. Bash also supports having function names with ":" in the name so you can namespace your commands like "./run lint:docker" or "./run lint:frontend".
I have a practical example of this sort of thing here: https://github.com/nickjj/docker-flask-example/blob/main/run
I've written about this pattern in more detail here https://nickjanetakis.com/blog/replacing-make-with-a-shell-s.... It's basically a less limited Makefile for when you want to make project specific aliases. This is something I use all the time now.