I love Git for Windows. It's just easy to move between Linux, Mac and Windows if I use the same tools.
Today I was wondering, how can I use bash from the terminal in Android Studio?
I ran into a blog post that explains how to do the same thing with Cygwin.
Since the Cygwin and git for Windows are similar I decided to give it a shot. Here are the steps:
-
Create
Bash-AndroidStudio.batincluded in this gist. -
@echo off set IDE=AndroidStudio "C:\Program Files\Git\bin\bash.exe" -
Add the following to your
.bashrcfile -
if [ ! -z "${IDE}" -a "${IDE}" == "AndroidStudio" ]; then cd $OLDPWD; fi -
In Android Studio, go to settings and add the path to your batch file in Tools > Terminal > Shell path.
Open a new terminal... voila!
#!/usr/bin/env bash
set -euo pipefail
apply_protection.sh
Automatyczne wgranie AURA Protection Suite do aktualnego repo.
Użycie: ./scripts/apply_protection.sh /ścieżka/do/aura_protection_suite_v2.zip
Jeśli nie podasz ścieżki do zip, skrypt szuka ./aura_protection_suite_v2.zip
ZIP_PATH="${1:-./aura_protection_suite_v2.zip}"
BRANCH="protection/aura-suite-v1-$(date -u +%Y%m%dT%H%M%SZ)"
TMP_DIR="$(mktemp -d)"
GIT_AUTHOR_NAME="${GIT_AUTHOR_NAME:-$(git config user.name || echo 'aura-bot')}"
GIT_AUTHOR_EMAIL="${GIT_AUTHOR_EMAIL:-$(git config user.email || echo 'dev@aura-idtoken.org')}"
SIGN_COMMITS="${SIGN_COMMITS:-true}" # jeśli chcesz, ustaw na false
echo ">>> AURA Protection apply script"
echo ">>> ZIP: ${ZIP_PATH}"
echo ">>> BRANCH: ${BRANCH}"
echo
if [ ! -f "${ZIP_PATH}" ]; then
echo "ERROR: ZIP not found at ${ZIP_PATH}"
exit 1
fi
1) extract zip to tmp
echo ">>> extracting zip to ${TMP_DIR}"
unzip -oq "${ZIP_PATH}" -d "${TMP_DIR}"
2) create branch
git fetch origin --prune || true
git checkout -b "${BRANCH}"
3) copy files into /PROTECTION
TARGET_DIR="PROTECTION"
mkdir -p "${TARGET_DIR}"
echo ">>> copying protection files to ${TARGET_DIR}/"
rsync -a --ignore-existing "${TMP_DIR}/" "${TARGET_DIR}/"
4) add README and PR template if missing
if [ ! -d ".github" ]; then mkdir -p .github; fi
if [ ! -f ".github/PULL_REQUEST_TEMPLATE.md" ]; then
cat > .github/PULL_REQUEST_TEMPLATE.md <<'PRT'
Cel PR
Dodaje AURA Protection Suite v1.0: licencje, specyfikację protokołu, architekturę defensywną, watermarking.
Checklist (wypełnić przed merge)
PRT
git add .github/PULL_REQUEST_TEMPLATE.md
fi
5) git add/commit
git add "${TARGET_DIR}" .github/PULL_REQUEST_TEMPLATE.md || true
COMMIT_MSG="chore: add AURA Protection Suite v1.0 (composite licenses, spec, defensive architecture)"
if [ "${SIGN_COMMITS}" = "true" ] && git config user.signingkey >/dev/null 2>&1; then
echo ">>> signing commit with GPG"
git -c user.name="${GIT_AUTHOR_NAME}" -c user.email="${GIT_AUTHOR_EMAIL}" commit -m "${COMMIT_MSG}" -S || true
else
git -c user.name="${GIT_AUTHOR_NAME}" -c user.email="${GIT_AUTHOR_EMAIL}" commit -m "${COMMIT_MSG}" || true
fi
6) push
echo ">>> pushing branch to origin"
git push -u origin "${BRANCH}"
7) create PR with gh CLI if present
if command -v gh >/dev/null 2>&1; then
echo ">>> creating PR (using gh)"
gh pr create --title "chore: add AURA Protection Suite v1.0"
--body "This PR adds the AURA Protection Suite v1.0 — composite license set, protocol spec (AIDS1), defensive architecture and watermarking spec. Please review licensing with legal counsel before merge."
--base main --head "${BRANCH}" || echo "gh pr create failed; create PR manually."
else
echo ">>> gh CLI not found — please open PR manually from branch ${BRANCH}"
fi
echo ">>> done. Branch: ${BRANCH}"