From 38666f88358cbb7bb2e02dc2c45d701f5b47a40c Mon Sep 17 00:00:00 2001 From: Andrew Stowell Date: Tue, 17 Oct 2023 02:53:52 +0000 Subject: [PATCH] new list all script, to easily document where things are. --- list-all.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 list-all.sh diff --git a/list-all.sh b/list-all.sh new file mode 100755 index 0000000..e4a1ea9 --- /dev/null +++ b/list-all.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# perform a "git remote -vv" on each location specified (recursively), or current location if none specified. +# git will quietly ignore any git repo stored in a folder you lack permission on. +# just listing where repos are located, and their remote. +# +# will only search symbolic links when passed "-l" option, must be before any locations +# list-all.sh [-l] # current location implied +# list-all.sh [-l] ~/my-projects /var/group-projects + +# check for "-l" in command prompt +followLinks="-H" +while getopts "l" option; do + case $option in + l) + followLinks="-L" + ;; + esac +done +shift "$((OPTIND-1))" + +if [[ "-H" == "$followLinks" ]]; then + echo "use -l to follow symbolic links" +fi + +# function to process each location +function process_git_list () { + startedIn=`pwd` + location=$(dirname "$@") + echo -n "----- git remote $location " + printf "%*.*s" 0 $((40 - ${#location} )) "----------------------------------------" + echo "-----" + cd "$location" + git remote -vv + cd "$startedIn" +} + +# find all folders named ".git" under given locations, +# and call process_git_list on each location that was found. +# we then work on the folder that contained the ".git" folder. + +find "$followLinks" "$@" -type d -name ".git" | while read -r file; do process_git_list "$file"; done +