Skip to content

Instantly share code, notes, and snippets.

@AbeEstrada
Last active December 26, 2025 00:25
Show Gist options
  • Select an option

  • Save AbeEstrada/1d6b859bcbdc81f8f94ff44258a0cdae to your computer and use it in GitHub Desktop.

Select an option

Save AbeEstrada/1d6b859bcbdc81f8f94ff44258a0cdae to your computer and use it in GitHub Desktop.
Toggle booleans
#!/usr/bin/env bash
if [[ $# -gt 0 ]]; then
input="$1"
else
read -r input _ <<< "$(cat)"
fi
if [[ -z "$input" ]]; then
exit 0
fi
case "$input" in
"true") echo "false" ;;
"false") echo "true" ;;
"True") echo "False" ;;
"False") echo "True" ;;
"TRUE") echo "FALSE" ;;
"FALSE") echo "TRUE" ;;
"1") echo "0" ;;
"0") echo "1" ;;
"YES") echo "NO" ;;
"NO") echo "YES" ;;
"yes") echo "no" ;;
"no") echo "yes" ;;
*) echo "$input" ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment