Skip to content

Instantly share code, notes, and snippets.

@AbeEstrada
Last active January 15, 2026 02:42
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" ;;
"True") echo "False" ;;
"TRUE") echo "FALSE" ;;
"false") echo "true" ;;
"False") echo "True" ;;
"FALSE") echo "TRUE" ;;
"1") echo "0" ;;
"0") echo "1" ;;
"yes") echo "no" ;;
"Yes") echo "No" ;;
"YES") echo "NO" ;;
"no") echo "yes" ;;
"No") echo "Yes" ;;
"NO") echo "YES" ;;
"and") echo "or" ;;
"And") echo "Or" ;;
"AND") echo "OR" ;;
"or") echo "and" ;;
"Or") echo "And" ;;
"OR") echo "AND" ;;
"on") echo "off" ;;
"On") echo "Off" ;;
"ON") echo "OFF" ;;
"off") echo "on" ;;
"Off") echo "On" ;;
"OFF") echo "ON" ;;
*) echo "$input" ;;
esac
@AbeEstrada
Copy link
Author

Helix Editor

[keys.normal.space.t]
t = ":pipe tog.sh"

@AbeEstrada
Copy link
Author

Neovim

vim.keymap.set("n", "<leader>t", function()
  local word = vim.fn.expand("<cword>")
  local output = vim.fn.system("echo -n " .. word .. " | tog.sh")
  output = output:gsub("%s+$", "")
  vim.api.nvim_command('normal! "_ciw' .. output)
end, { desc = "Toggle word under cursor using 'tog.sh' shell command" })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment