[zsh] Autoload the bool function

This commit is contained in:
Eryn Wells 2025-08-01 10:38:48 -07:00
parent 6dc9120dd0
commit fa0e59ea39
2 changed files with 14 additions and 13 deletions

View file

@ -2,30 +2,30 @@
# vim: set ft=zsh: # vim: set ft=zsh:
function bool { function bool {
if [[ $1 -eq 0 ]]; then if [[ "$1" =~ '^-?[0-9]+$' ]]; then
echo "no" if (( $1 == 0 )); then
return false echo "no"
return 1
else
echo "yes"
return 0
fi
fi fi
local lowercase_value=${(L)1} local lowercase_value=${(L)1}
if [[ "$lowercase_value" == "yes" ]]; then if [[ "$lowercase_value" == "yes" || "$lowercase_value" == "true" ]]; then
echo "yes" echo "yes"
return true return 0
fi fi
if [[ "$lowercase_value" == "no" ]]; then if [[ "$lowercase_value" == "no" || "$lowercase_value" == "false" ]]; then
echo "no" echo "no"
return false return 1
fi
if [[ "$lowercase_value" =~ '^[0-9]+$' ]]; then
echo "yes"
return true
fi fi
echo "no" echo "no"
return false return 1
} }
bool "$@" bool "$@"

1
zshrc
View file

@ -21,6 +21,7 @@ fi
do_init_functions zsh_init_rc_functions do_init_functions zsh_init_rc_functions
autoload -Uz bool
autoload -Uz g autoload -Uz g
autoload -Uz nethack autoload -Uz nethack
autoload -Uz pw autoload -Uz pw