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.
Serve Jekyll / Hugo websites
I maintain several websites using Jekyll and Hugo. To build these sites, I simply type:
serve
Which invokes the following function:
function serve() {
cd $(git rev-parse --show-toplevel)
if [ -f "scripts/serve-latest.sh" ]; then
scripts/serve-latest.sh
elif [ -f "scripts/serve.sh" ]; then
scripts/serve.sh
elif [ -f "config.toml" ]; then
hugo server
else
jekyll serve
fi || play -q -n synth 0.05 sin 480
}
This also beeps upon failure! :-)
Note: The
scripts/serve*.sh
files are used in the DuckDB documentation pages.