mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-20 14:55:22 +00:00
feat(scripts): use bkt for command caching
This commit is contained in:
@@ -197,11 +197,32 @@ function menu_usage()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
# shorthand for checking if the system has the bin in path.
|
# shorthand for checking if the system has the bin in path.
|
||||||
# usage: have php && php -v
|
# usage: have php && php -v
|
||||||
function have
|
function have
|
||||||
{
|
{
|
||||||
command -v "$1" >&/dev/null
|
bkt -- command -v "$1" >&/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
function brew_installed
|
||||||
|
{
|
||||||
|
bkt -- brew list
|
||||||
}
|
}
|
||||||
|
|
||||||
# shorthand for checking if brew package is installed
|
# shorthand for checking if brew package is installed
|
||||||
@@ -210,7 +231,7 @@ function have_brew
|
|||||||
{
|
{
|
||||||
! have brew && return 125
|
! have brew && return 125
|
||||||
|
|
||||||
if brew list "$1" &> /dev/null; then
|
if bkt -- brew list "$1" &> /dev/null; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
Reference in New Issue
Block a user