Skip to content

Instantly share code, notes, and snippets.

@pwd491
Last active May 7, 2025 03:10
Show Gist options
  • Save pwd491/d812f1c62f99627aaa3d374d8564930d to your computer and use it in GitHub Desktop.
Save pwd491/d812f1c62f99627aaa3d374d8564930d to your computer and use it in GitHub Desktop.
Download gitignore script
@echo off
setlocal enabledelayedexpansion
:: Checking for arguments
if "%~1"=="" (
echo Use: %~nx0 [arguments separated by commas]
echo Example: %~nx0 windows,python,visualstudiocode
echo List of available: %~nx0 list
exit /b 1
)
:: Forming the URL from the arguments
set "params=%*"
set "params=!params: =,!"
set "url=https://www.toptal.com/developers/gitignore/api/!params!"
:: List of available arguments
if "%~1"=="list" (
echo:
curl !url!
exit /b 1
)
:: Download .gitignore
echo Downloading .gitignore for: !params!
curl --fail --silent --show-error !url! > .gitignore
:: Checking the success of the download
if %ERRORLEVEL% neq 0 (
echo Error download .gitignore
del .gitignore 2>nul
exit /b 1
)
:: Checking the file contents
findstr /i /c:"# Created by" .gitignore >nul
if %ERRORLEVEL% neq 0 (
echo Got uncorrect .gitignore
type .gitignore
del .gitignore 2>nul
pause
exit /b 1
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment