Last active
June 6, 2020 13:21
-
-
Save depressiveRobot/626e7066e77da1659c97 to your computer and use it in GitHub Desktop.
bash function to override git init/clone commands
This file contains hidden or 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
| function git() { | |
| if [[ "$1" = "init" ]] # ask for email after init | |
| then | |
| /usr/local/bin/git $@ | |
| git-email-prompt.sh | |
| elif [[ "$1" = "clone" ]] # ask for email after clone | |
| then | |
| /usr/local/bin/git $@ | |
| if [[ "$3" = "" ]] # no directory given, extract from repo name | |
| then | |
| cd $(echo $2 | awk -F/ '{ print $NF }' | rev | sed 's/tig.//' | rev) | |
| else | |
| cd $3 | |
| fi | |
| git-email-prompt.sh | |
| else | |
| /usr/local/bin/git $@ | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that you don't have to enter the repo to set the email - with new enough versions of Git, you can pass configuration options at clone-time. This means you won't have to bother with getting the directory.
See how I solve the email problem here: https://github.com/jan-warchol/dotfiles/blob/devel/bin/git-cln