diff --git a/git-sync b/git-sync new file mode 100755 index 0000000..75c8213 --- /dev/null +++ b/git-sync @@ -0,0 +1,23 @@ +#!/usr/bin/env zsh + +autoload -U colors && colors + +git_sync=${GIT_SYNC:-~/.config/git-sync} + +if [ ! -f "$git_sync" ]; then + echo "$fg[yellow]warning:${reset_color} sync list does not exist: $git_sync" + exit 0 +fi + + +local repos=($(cat $git_sync)) +if [ ${#repos[@]} = 0 ]; then + echo "$fg[yellow]warning:${reset_color} sync list is empty: $git_sync" + exit 0 +fi + +for repo in $repos; do + print -P "$fg[cyan]synchronizing: $repo${reset_color}" + repo="${repo/#\~/$HOME}" + git -C "$repo" fetch -a +done diff --git a/tasks.yaml b/tasks.yaml index cb3fffb..6be8da9 100644 --- a/tasks.yaml +++ b/tasks.yaml @@ -27,3 +27,5 @@ dest: ~/.gitconfig - src: ~/.config/git/_git-changes dest: ~/.local/share/zsh/site-functions/_git-changes + - src: ~/.config/git/git-sync + dest: ~/.local/bin/git-sync