dotfiles/lib/functions.zsh
2019-01-09 18:55:19 +02:00

32 lines
422 B
Bash

#!/usr/bin/env zsh
is_linux() {
[[ "$OSTYPE" == linux* ]]
}
is_macos() {
[[ "$OSTYPE" == darwin* ]]
}
is_android() {
[[ "$OSTYPE" == linux-android ]]
}
command_exists() {
command -v "$1" >/dev/null 2>&1
}
source_if_exists() {
[[ -f "$1" ]] && source "$1"
}
lazy_load() {
local command="$1"
local init_command="$2"
eval "$command() {
unfunction $command
$init_command
$command \$@
}"
}