# Cache commands using bkt if installed
if command -v bkt >&/dev/null; then
bkt() { command bkt "$@"; }
else
# If bkt isn't installed skip its arguments and just execute directly.
# Optionally write a msg to stderr suggesting users install bkt.
bkt() {
while [[ "$1" == --* ]]; do shift; done
"$@"
}
fi
# Now you can call bkt (the function) just like you'd call bkt (the binary):
bkt -- expensive_cmd ...
https://github.com/dimo414/bkt
Def. use the "decorator" method for it: