Skip to content

Instantly share code, notes, and snippets.

@ganobrega
Last active March 18, 2025 19:20
Show Gist options
  • Save ganobrega/95d330fe1232c387f76084510257811e to your computer and use it in GitHub Desktop.
Save ganobrega/95d330fe1232c387f76084510257811e to your computer and use it in GitHub Desktop.
Setup WindowsDevEnvironment

Setup Windows Development Environment

Este repositório contém um script PowerShell para configurar rapidamente um ambiente de desenvolvimento no Windows. Ele instala vários pacotes úteis, configura o Windows Terminal para usar o Git Bash como shell padrão, e executa outras configurações importantes.

Como Usar

Para usar o script e configurar seu ambiente de desenvolvimento no Windows, siga os passos abaixo:

  1. Abra o PowerShell como Administrador.
  2. Execute o seguinte comando para baixar e executar o script:
Invoke-WebRequest -Uri "https://gist.githubusercontent.com/ganobrega/95d330fe1232c387f76084510257811e/raw/Setup-WindowsDevEnvironment.ps1" -OutFile "$env:TEMP\Setup-WindowsDevEnvironment.ps1"; Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force; & "$env:TEMP\Setup-WindowsDevEnvironment.ps1"

ou

irm "https://gist.githubusercontent.com/ganobrega/95d330fe1232c387f76084510257811e/raw/Setup-WindowsDevEnvironment.ps1" | iex

Como configurar o Android Studio corretamente

<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="notepadplusplus.install" name="Notepad++" />
<package id="googlechrome" name="Google Chrome" />
<package id="vscode" name="Visual Studio Code" />
<package id="spotify" name="Spotify" />
<package id="1password" name="1Password" />
<package id="logioptionsplus" name="Logi Options+" version="1.46.425296" />
<package id="git.install" name="Git" />
<package id="github-desktop" name="GitHub Desktop" />
<package id="gh" name="GitHub CLI" />
<package id="nvm" name="NVM (Node Version Manager)" />
<package id="deno" name="Deno" />
<package id="bun" name="Bun" />
<package id="python" version="3.13.0-rc2" prerelease="true"/>
<package id="postman" name="Postman" />
<package id="winrar" name="Winrar" />
<package id="pinwin" name="PinWin" />
<package id="jcpicker" name="PinWin" />
<package id="insomnia-rest-api-client" name="Insomnia" />
</packages>
# Definir diretório para armazenar o arquivo packages.config, logs e downloads
$basePath = "C:/temp/Setup-WindowsDevEnvironment"
$logPath = "$basePath/logs"
$downloadsPath = "$basePath/downloads"
$packagesConfigPath = "$basePath/packages.config"
$logFile = "$logPath/install_log.txt"
# Criar diretórios caso não existam
if (!(Test-Path -Path $basePath)) {
New-Item -ItemType Directory -Path $basePath
}
if (!(Test-Path -Path $logPath)) {
New-Item -ItemType Directory -Path $logPath
}
if (!(Test-Path -Path $downloadsPath)) {
New-Item -ItemType Directory -Path $downloadsPath
}
if (Test-Path $logFile) {
Remove-Item -Path $logFile -Force
}
# Baixar o arquivo packages.config da URL fornecida
$packagesUrl = "https://gist.githubusercontent.com/ganobrega/95d330fe1232c387f76084510257811e/raw/packages.config"
Write-Host "Baixando o arquivo packages.config..." -ForegroundColor Yellow
Invoke-WebRequest -Uri $packagesUrl -OutFile $packagesConfigPath
# Verifica se o Chocolatey está instalado
if (!(Get-Command choco -ErrorAction SilentlyContinue)) {
Write-Host "Chocolatey não está instalado. Instalando agora..." -ForegroundColor Yellow
# Configura a política de execução para permitir scripts remotos temporariamente
Set-ExecutionPolicy Bypass -Scope Process -Force
# Baixa e instala o Chocolatey
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Verifica novamente se o Chocolatey foi instalado com sucesso
if (Get-Command choco -ErrorAction SilentlyContinue) {
Write-Host "Chocolatey foi instalado com sucesso!" -ForegroundColor Green
} else {
Write-Host "Falha ao instalar o Chocolatey. Verifique a conexão com a internet ou permissões administrativas." -ForegroundColor Red
exit 1
}
} else {
Write-Host "Chocolatey já está instalado no sistema." -ForegroundColor Green
}
# Instalar pacotes usando o comando choco install com o arquivo packages.config
Write-Host "Iniciando a instalação dos pacotes..." -ForegroundColor Yellow
try {
choco install $packagesConfigPath -y
Write-Host "Instalação concluída com sucesso!" -ForegroundColor Green
} catch {
Write-Host "Falha ao instalar os pacotes. Verifique o arquivo packages.config." -ForegroundColor Red
Add-Content -Path $logFile -Value "Falha ao instalar pacotes: $($_.Exception.Message)"
}
# Instalar o Windows Terminal usando o winget
Write-Host "Instalando o Windows Terminal..." -ForegroundColor Yellow
try {
winget install --id Microsoft.WindowsTerminal -e --source msstore
Write-Host "Windows Terminal instalado com sucesso!" -ForegroundColor Green
} catch {
Write-Host "Falha ao instalar o Windows Terminal. Verifique o winget." -ForegroundColor Red
Add-Content -Path $logFile -Value "Falha ao instalar o Windows Terminal: $($_.Exception.Message)"
}
# Verifica se o WSL está instalado
Write-Host "Verificando instalação do WSL..." -ForegroundColor Yellow
$wslFeature = Get-WindowsOptionalFeature -Online | Where-Object { $_.FeatureName -eq "Microsoft-Windows-Subsystem-Linux" }
if ($wslFeature.State -eq "Enabled") {
Write-Host "WSL já está instalado no sistema." -ForegroundColor Green
} else {
Write-Host "WSL não está instalado. Instalando agora..." -ForegroundColor Yellow
# Ativa o WSL
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart -ErrorAction Stop
# Instala o WSL 2 e o kernel necessário
wsl --install
Write-Host "WSL foi instalado com sucesso!" -ForegroundColor Green
}
# Configura o Git Bash como o perfil padrão no Windows Terminal
Write-Host "Configurando o Git Bash como perfil padrão no Windows Terminal..." -ForegroundColor Yellow
$settingsPath = "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json"
# Verifica se o arquivo settings.json existe
if (Test-Path $settingsPath) {
# Lê o conteúdo do arquivo settings.json
$settingsJson = Get-Content -Path $settingsPath -Raw | ConvertFrom-Json
# Encontra o perfil do Git Bash e altera o valor de defaultProfile
$gitBashProfile = $settingsJson.profiles.list | Where-Object { $_.name -eq "Git Bash" }
if ($gitBashProfile) {
$settingsJson.defaults.profile = $gitBashProfile.guid
# Salva as alterações no arquivo settings.json
$settingsJson | ConvertTo-Json -Depth 10 | Set-Content -Path $settingsPath -Force
Write-Host "Git Bash configurado como perfil padrão no Windows Terminal." -ForegroundColor Green
} else {
Write-Host "Não foi encontrado o perfil 'Git Bash' no Windows Terminal." -ForegroundColor Red
}
} else {
Write-Host "Arquivo settings.json do Windows Terminal não encontrado." -ForegroundColor Red
}
# Instalar o Raindrop.io através do winget (Windows Store)
Write-Host "Instalando o Raindrop.io da Windows Store..." -ForegroundColor Yellow
try {
winget install --id Raindrop.Raindrop -e --source msstore
Write-Host "Raindrop.io instalado com sucesso!" -ForegroundColor Green
} catch {
Write-Host "Falha ao instalar o Raindrop.io. Verifique o winget." -ForegroundColor Red
Add-Content -Path $logFile -Value "Falha ao instalar o Raindrop.io: $($_.Exception.Message)"
}
# Baixar e abrir o Lightshot
try {
Write-Host "Baixando o Lightshot..." -ForegroundColor Yellow
$lightshotUrl = "https://app.prntscr.com/build/setup-lightshot.exe"
$lightshotFile = "$downloadsPath\LightshotSetup.exe"
Invoke-WebRequest -Uri $lightshotUrl -OutFile $lightshotFile
Start-Process $lightshotFile
Write-Host "Lightshot instalado e aberto." -ForegroundColor Green
} catch {
Write-Host "Falha ao instalar o Lightshot." -ForegroundColor Red
Add-Content -Path $logFile -Value "Falha ao instalar o Lightshot: $($_.Exception.Message)"
}
# Instalar o Chris Titus Tech's Windows Utility
try {
# Executar o comando final solicitado
Write-Host "Executando o comando solicitado..." -ForegroundColor Yellow
irm "https://christitus.com/win" | iex
} catch {
Write-Host "Falha ao instalar o ChristitusWin." -ForegroundColor Red
Add-Content -Path $logFile -Value "Falha ao instalar o ChristitusWin: $($_.Exception.Message)"
}
# Criar um ponto de restauração no Windows
Write-Host "Criando um ponto de restauração do sistema..." -ForegroundColor Yellow
$restorePointName = "Ponto de Restauração - $((Get-Date).ToString('yyyy-MM-dd_HH-mm-ss'))"
try {
Checkpoint-Computer -Description $restorePointName -RestorePointType "MODIFY_SETTINGS"
Write-Host "Ponto de restauração criado com sucesso!" -ForegroundColor Green
} catch {
Write-Host "Falha ao criar ponto de restauração: $($_.Exception.Message)" -ForegroundColor Red
Add-Content -Path $logFile -Value "Falha ao criar ponto de restauração: $($_.Exception.Message)"
}
Write-Host "Processo concluído!" -ForegroundColor Green
# Exibe mensagem com caminho do log em caso de falha
if (Test-Path $logFile) {
Write-Host "Alguns erros ocorreram durante a execução. Consulte o log em: $logFile" -ForegroundColor Yellow
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment