File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed
Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -257,26 +257,22 @@ the user starts navigating the selector.
257257### Using ` bkt ` only if installed
258258
259259You may want to distribute shell scripts that utilize ` bkt ` without requiring
260- every user also install ` bkt ` . By wrapping ` bkt ` in a shell function your script
261- can cleanly invoke ` bkt ` if available without complicating your users' workflow.
262- Of course if they choose to install ` bkt ` they'll get a faster script as a
263- result!
260+ every user also install it . By falling back to a no-op shell function when ` bkt `
261+ is not available your script can take advantage of it opportunistically without
262+ complicating your users' workflow. Of course if they choose to install ` bkt `
263+ they'll get a faster script as a result!
264264
265265``` shell
266266# Cache commands using bkt if installed
267- if command -v bkt >& /dev/null; then
268- bkt () { command bkt " $@ " ; }
269- else
267+ if ! command -v bkt >& /dev/null; then
270268 # If bkt isn't installed skip its arguments and just execute directly.
271- # Optionally write a msg to stderr suggesting users install bkt.
272269 bkt () {
273270 while [[ " $1 " == --* ]]; do shift ; done
274271 " $@ "
275272 }
273+ # Optionally, write a msg to stderr suggesting users install bkt.
274+ echo " Tip: install https://github.com/dimo414/bkt for faster performance" >&2
276275fi
277-
278- # Now you can call bkt (the function) just like you'd call bkt (the binary):
279- bkt --ttl=1m -- expensive_cmd ...
280276```
281277
282278### Decorating commands with ` bkt ` in shell scripts
You can’t perform that action at this time.
0 commit comments