Browse Source

gitup: specify multiple dirs to search

DanielFGray 2 years ago
parent
commit
f0cee3c280
1 changed files with 13 additions and 8 deletions
  1. 13
    8
      gitup

+ 13
- 8
gitup View File

@@ -7,6 +7,7 @@ colors[blue]=$(tput setaf 4)
7 7
 colors[reset]=$(tput sgr0)
8 8
 declare processes=4
9 9
 declare quiet
10
+declare -a dirs
10 11
 
11 12
 usage() {
12 13
   LESS=-FEXR less <<'HELP'
@@ -67,15 +68,19 @@ while getopts ":hqp:" x; do
67 68
 done
68 69
 shift $(( OPTIND - 1 ))
69 70
 
70
-dir="$HOME"
71
-if [[ -d "$1" ]]; then
72
-  dir="$1"
73
-fi
71
+while :; do
72
+  if [[ -d "$1" ]]; then
73
+    dirs+=( "$1" )
74
+  fi
75
+  shift || break
76
+done
77
+
78
+(( ${#dirs[@]} > 0 )) || dirs=("$HOME")
74 79
 
75
-mapfile -t dirs < <(find -L "$dir" -name '.git' -printf '%h\n' 2> /dev/null \
80
+mapfile -t repos < <(find -L "${dirs[@]}" -name '.git' -printf '%h\n' 2> /dev/null \
76 81
   | fzf --multi --cycle --inline-info)
77 82
 
78
-(( ${#dirs[@]} > 0 )) || exit
83
+(( ${#repos[@]} > 0 )) || exit
79 84
 
80 85
 update() {
81 86
   local name dir
@@ -89,10 +94,10 @@ update() {
89 94
   fi
90 95
 }
91 96
 
92
-for d in "${dirs[@]}"; do
97
+for d in "${repos[@]}"; do
93 98
   (( count++ >= processes )) && wait -n
94 99
   update "$d" &
95 100
 done
96 101
 wait
97 102
 
98
-printf '%d repos updated\n' "${#dirs[@]}"
103
+printf '%d repos updated\n' "${#repos[@]}"

Loading…
Cancel
Save