Make git
beep upon failed push
Motivation: When I issue a
git push
command, I immediately navigate away from the terminal. Therefore, if the command fails due to the remote rejecting it after a second, I do not see this and assume that the push was successful.
To avoid this, we’ll configure the shell so when git push
fails, it gives a small beep sound.
To do so, follow these steps:
-
Install
SoX
:brew install sox
-
Test SoX:
play -q -n synth 0.05 sin 480
-
Add the following to your
~/.zshrc
file:function git { if [ ${#} -gt 1 ] && [ ${1} = "push" ]; then /usr/bin/git ${@} || play -q -n synth 0.05 sin 480 else /usr/bin/git "${@}" fi }
-
To test the command, open a new terminal and try pushing to a non-existent remote:
git push asd
It should beep.