From 517cf4517450c1d8c9206fad31c2416c3098c080 Mon Sep 17 00:00:00 2001 From: bretello Date: Wed, 14 Jul 2021 10:19:21 +0200 Subject: [PATCH] functions: add retry function --- functions.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/functions.sh b/functions.sh index ef7894b..b8e9961 100755 --- a/functions.sh +++ b/functions.sh @@ -290,8 +290,17 @@ fvim() { fi } +# retry command until it succeeds (waiting one second or $RETRY_INTERVAL) +function retry() { + local _retry_interval + if [[ -z "$RETRY_INTERVAL" ]]; then _retry_interval=1; else _retry_interval=$RETRY_INTERVAL; fi + until $@; do sleep $RETRY_INTERVAL; done +} + +# Creats a gitignore for the given argument (e.g. python, cpp, etc) +function gi() { curl -sL https://www.toptal.com/developers/gitignore/api/$@; } + # dotfiles user functions if [[ -f $HOME/.dotfiles_functions ]]; then source "$HOME/.dotfiles_functions" fi -function gi() { curl -sL https://www.toptal.com/developers/gitignore/api/$@ ;}