Skip to content

Instantly share code, notes, and snippets.

@manuerumx
Last active February 1, 2019 11:26
Show Gist options
  • Save manuerumx/64f5aaa1415e055c0be664f54ad32680 to your computer and use it in GitHub Desktop.
Save manuerumx/64f5aaa1415e055c0be664f54ad32680 to your computer and use it in GitHub Desktop.
Update repositories in batch
#!/bin/sh
function printdash(){
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
}
function ini_update(){
REPO=${PWD##*/}
COLUMNS=$(tput cols)
printdash
title="Updating $REPO repository"
printf "%*s\n" $(((${#title}+$COLUMNS)/2)) "$title"
echo
}
function end_update(){
echo
REPO=${PWD##*/}
COLUMNS=$(tput cols)
title=" $REPO repository updated"
printf "%*s\n" $(((${#title}+$COLUMNS)/2)) "$title"
printdash
}
declare -a arr=("directory/repository" "directory/repository2")
for i in "${arr[@]}"
do
cd ~/"$i"
ini_update
git pull --prune origin
end_update
done
cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment