From 5d0c82a79d58d530e7520d5bd0a1e97217ab1470 Mon Sep 17 00:00:00 2001 From: hophacker Date: Wed, 24 Jul 2019 13:27:22 +0800 Subject: [PATCH] add gitr which recursively executes git commands --- zsh/functions.zsh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/zsh/functions.zsh b/zsh/functions.zsh index 4ce82c1..408dbf0 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -135,8 +135,7 @@ function init_db() { dc exec $1 rails db:drop db:create db:migrate db:seed } function cmd_exists() { - cmd=$1 - $cmd &> /dev/null; + $* &> /dev/null if [[ $? == 0 ]]; then echo Y else @@ -181,6 +180,19 @@ function qshell_upload() { qshell rput $bucket $key $filepath } +function gitr() { + args=$* + for dir in `ls`; do + if [[ -d "$dir" && -d "$dir/.git" ]]; then + pushd . + echo "${GREEN}$(basename $dir)${NC}" + cd $dir + git $args + popd + fi + done +} + function gitcopy() { n=1 while getopts "c:n:t:T" o; do