Skip to content

Instantly share code, notes, and snippets.

@imliam
Created July 9, 2026 14:24
Show Gist options
  • Select an option

  • Save imliam/a7bde426669913b5df7b52a94688cc6d to your computer and use it in GitHub Desktop.

Select an option

Save imliam/a7bde426669913b5df7b52a94688cc6d to your computer and use it in GitHub Desktop.
[alias]
get = "!f() { \
if [ -z \"$1\" ]; then \
echo \"Error: no repository specified.\" >&2; \
echo \"Usage: git get <url|owner/repo> [directory]\" >&2; \
return 1; \
fi; \
REPOSITORY_ARGUMENT=\"$1\"; \
case \"$REPOSITORY_ARGUMENT\" in \
*://*|git@*) REPOSITORY_URL=\"$REPOSITORY_ARGUMENT\";; \
*/*) REPOSITORY_URL=\"https://github.com/${REPOSITORY_ARGUMENT%.git}.git\";; \
*) echo \"Error: '$REPOSITORY_ARGUMENT' is not a valid repository URL or owner/repo shorthand.\" >&2; return 1;; \
esac; \
REPOSITORY_NAME=$(echo \"$REPOSITORY_URL\" | awk -F/ '{print $NF}' | sed 's/.git$//i'); \
TARGET_DIRECTORY=\"${2:-$REPOSITORY_NAME}\"; \
echo \"Cloning repository: $REPOSITORY_NAME\"; \
echo \"From: $REPOSITORY_URL\"; \
echo \"Into: $TARGET_DIRECTORY\"; \
git clone \"$REPOSITORY_URL\" \"$TARGET_DIRECTORY\" || return 1; \
if [ -f \"$TARGET_DIRECTORY/composer.json\" ]; then composer install --working-dir=\"$TARGET_DIRECTORY\"; fi; \
( \
cd \"$TARGET_DIRECTORY\" || exit 1; \
if [ -f .nvmrc ]; then \
if command -v fnm >/dev/null 2>&1; then \
echo \"Found .nvmrc, using fnm...\"; \
fnm install && fnm use; \
elif [ -s \"$NVM_DIR/nvm.sh\" ]; then \
echo \"Found .nvmrc, using nvm...\"; \
. \"$NVM_DIR/nvm.sh\" && nvm install && nvm use; \
else \
echo \"Found .nvmrc, but neither fnm nor nvm is available: skipping Node version setup.\"; \
fi; \
fi; \
if [ -f package.json ]; then \
if [ -f bun.lockb ] || [ -f bun.lock ]; then bun install; \
elif [ -f pnpm-lock.yaml ]; then pnpm install; \
elif [ -f yarn.lock ]; then yarn install; \
else npm install; fi; \
fi; \
); \
if [ -f \"$TARGET_DIRECTORY/artisan\" ]; then php ./\"$TARGET_DIRECTORY/artisan\" key:generate; fi; \
if [ -n \"${EDITOR}\" ]; then ${EDITOR} \"$TARGET_DIRECTORY\"; fi; \
};f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment