Last active
July 12, 2023 14:06
-
-
Save MrSwed/4bb4e0a8c2a2f35827e6d9b410642582 to your computer and use it in GitHub Desktop.
Enable or Disable git hooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Enable or disable git hooks | |
#find .git/hooks/ -type f ! -name "*.*" | |
gitHooks=.git/hooks/ | |
echo "git Hooks $gitHooks" | |
option="${1}" | |
case ${option} in | |
"--help" | "-h" | "/?" | "-?" ) | |
echo "Usage: $0 <command> | |
<command> | |
on - Enable hooks | |
off - disable hooks | |
--help - This help | |
" | |
;; | |
"on" ) echo "$1 Selected" | |
find $gitHooks -type f -name "*.off" | grep "" >/dev/null || ( | |
echo Nothing to $1 | |
exit 0 | |
) | |
find $gitHooks -type f -name "*.off" -exec sh -c 'mv -v "$1" "${1%.off}"' _ {} \; | |
;; | |
"off" ) echo "$1 Selected" | |
find $gitHooks -type f ! -name "*.*" | grep "" >/dev/null || ( | |
echo Nothing to $1 | |
exit 0 | |
) | |
find $gitHooks -type f ! -name "*.*" -exec sh -c 'mv -v "$1" "${1%}.off"' _ {} \; | |
;; | |
"" ) | |
echo "Current status:" | |
find $gitHooks -type f ! -name "*.*" | |
find $gitHooks -type f -name "*.off" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! This just helped me a lot. Was about to write sth. like this on my own, but then found this. 💖