Skip to content

Instantly share code, notes, and snippets.

@salmin89
Created April 4, 2022 19:23
Show Gist options
  • Save salmin89/09b8b128ab9e7db15d3f7db9d9c7804b to your computer and use it in GitHub Desktop.
Save salmin89/09b8b128ab9e7db15d3f7db9d9c7804b to your computer and use it in GitHub Desktop.
shell scripts to perform commands on multiple repos at once
#usage oa -p /proj1/ -p /proj2/ git checkout master
while getopts "p:" flag; do
case $flag in
p) paths+=("$OPTARG");;
*) echo "Unexpected option ${flag}"; exit 1;;
esac
done
shift $(expr $OPTIND - 1 )
for path in "${paths[@]}"; do
( cd $path && $@)
done
#usage: oo git checkout master
#set your root dirr to all your repos
ROOT="$HOME/src"
#set you vscode workspace file
WORKSPACE_CONFIG="$ROOT/src.code-workspace"
# grab current config file | strip commented lines | jq to grab the paths
paths=($(cat $WORKSPACE_CONFIG | sed 's/\/\/.*//' | jq -r '.folders[].path' ))
#exec on all open
for path in "${paths[@]}"; do
echo ">>>$path<<<"
( cd "$ROOT/$path" && $@)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment