From 4200ea9613c2e80afed42627c4cd2219013586eb Mon Sep 17 00:00:00 2001 From: "flyingscorpio@pinebookpro" Date: Sun, 5 Sep 2021 10:32:07 +0200 Subject: [PATCH] Move find command into function + minor changes --- dotfiles/shell/aliases | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dotfiles/shell/aliases b/dotfiles/shell/aliases index aa1e69e..892757b 100644 --- a/dotfiles/shell/aliases +++ b/dotfiles/shell/aliases @@ -66,9 +66,6 @@ clitip() { xmlstarlet unesc | fmt -80 | iconv -t US } -#GIT_REPOS=($(find ~ -name .git -type d -not -path '*/.vim/*' -and -not -path '*/.local/*' -and -not -path '*/builds/*' -exec dirname {} \;)) -GIT_REPOS=(~/src/* ~/setup-cockpit ~/tssr ~/.password-store) - cockpit() { # enable pass-like commands (ex: cockpit git push) local start_dir="$PWD" cd ~/setup-cockpit && "$@" @@ -90,13 +87,14 @@ system_update() { aur_update() { local start_dir="$PWD" - for repo in $(find ~/builds -name .git -type d -exec dirname {} \;); do + local aur_packages; aur_packages=($(find ~/builds -name .git -type d -exec dirname {} \;)) + for repo in "${aur_packages[@]}"; do cd && cd "$repo" && git fetch -q - local unpulled=$(git log --pretty=format:'%h' ..@{u} | wc -c) + local unpulled; unpulled=$(git log --pretty=format:'%h' '..@{u}' | wc -c) if [ "$unpulled" -eq 0 ]; then echo "$(basename "$repo") is up to date" else - git pull && git log --no-merges --oneline --stat @{1}.. -p + git pull && git log --no-merges --oneline --stat '@{1}..' -p echo -n "Update $repo? [y/N] " read -r answer if [ ! "$answer" = 'y' ]; then @@ -111,7 +109,8 @@ aur_update() { pull_from_repos() { local start_dir="$PWD" - for repo in "${GIT_REPOS[@]}"; do + local git_repos; git_repos=($(find ~ -name .git -type d -not -path '*/.vim/*' -and -not -path '*/.local/*' -and -not -path '*/builds/*' -exec dirname {} \;)) + for repo in "${git_repos[@]}"; do echo "Pulling from $repo..." cd "$repo" && git pull done