Created
March 25, 2022 14:08
-
-
Save jimbrig/8ff07475181691cc2468cec5b384fe77 to your computer and use it in GitHub Desktop.
Scoop Configuration and Installation for R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# check execution policy | |
If ((Get-ExecutionPolicy) -eq 'Restricted') { | |
Set-ExecutionPolicy Unrestricted -Scope CurrentUser | |
} | |
# check powershell $PROFILE | |
If (!(Test-Path $PROFILE)) { | |
Write-Host "No PowerShell $PROFILE detected, creating one.." -ForegroundColor Magenta | |
New-Item -ItemType File -Path $PROFILE -Force | |
Write-Host "Created PowerShell Profile at: $PROFILE" -ForegroundColor Green | |
} | |
Write-Host "Setting up powershell profile..." -ForegroundColor Magenta | |
Write-Output "# Remove default powershell alias for r:`nrm alias: \r`n" >> $PROFILE | |
Write-Host "Successfully removed default r alias using powershell profile." -ForegroundColor Green | |
# install scoop | |
Write-Host "Installing Scoop..." -ForegroundColor Magenta | |
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh') | |
Write-Host "Successfully installed scoop." -ForegroundColor Green | |
# install git, pandoc, 7zip | |
Write-Host "Installing git due to scoop's dependency on it..." -ForegroundColor Magenta | |
scoop install git | |
Write-Host "Successfully installed git." -ForegroundColor Green | |
# Checkup | |
Write-Host "Checking Scoop..." -ForegroundColor Magenta | |
scoop checkup | |
Write-Host "Successfully ran scoop checkup." -ForegroundColor Green | |
# Add Buckets | |
Write-Host "Adding scoop buckets..." -ForegroundColor Magenta | |
scoop bucket add main | |
scoop bucket add extras | |
Write-Host "Successfully added buckets for scoop." -ForegroundColor Green | |
Write-Host "Current scoop buckets:" -ForegroundColor Yellow | |
scoop bucket list | |
# completion | |
Write-Host "Installing scoop-completion for powershell profile..." -ForegroundColor Magenta | |
scoop install scoop-completion | |
Write-Host "Successfully installed scoop-completion." -ForegroundColor Green | |
Write-Host "Adding scoop-completion to powershell profile..." -ForegroundColor Magenta | |
Add-Content -Path $Profile -Value "`n# Scoop Completion:`nImport-Module $env:USERPROFILE\scoop\modules\scoop-completion`n" -Force | |
Write-Host "Successfully added completion code to powershell profile." -ForegroundColor Green | |
# User Installs | |
Write-Host "Installing user apps using scoop: aria2, 7Zip, Pandoc, and curl..." -ForegroundColor Magenta | |
scoop install aria2 7zip pandoc curl | |
Write-Host "Successfully installed aria2, Pandoc, curl, and 7zip" -ForegroundColor Green | |
# install r, rtools, and rstudio | |
Write-Host "Installing R, RTools, and RStudio..." -ForegroundColor Magenta | |
scoop install r rstudio | |
scoop install rtools -s | |
Write-Host "Successfully installed R, RTools, and RStudio." | |
Write-Host "Configuring .RProfile..." -ForegroundColor Magenta | |
Write-Output "`n# Options:`noptions( | |
repos = c(CRAN = \"https://cran.rstudio.com\"), | |
download.file.method = \"libcurl\" | |
)`n" >> "$HOME\.Rprofile" | |
Write-Host "Configuring .Renviron..." -ForegroundColor Magenta | |
Write-Output "PATH=\"${RTOOLS40_HOME}\usr\bin;${PATH}\"" >> "$HOME\.Renviron" | |
Write-Host "Successfully setup .Rprofile and .Renviron" -ForegroundColor Green |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment