Last active
August 18, 2022 15:10
-
-
Save jeebak/8064d35757c99b0cd507 to your computer and use it in GitHub Desktop.
My Boxstarter Script
This file contains 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
# | |
# https://github.com/tknerr/bills-kitchen | |
# All you need for cooking with Chef and Vagrant on Windows you will find in Bill's Kitchen | |
# https://github.com/tknerr/linus-kitchen | |
# An Ubuntu-based developer VM for hacking with Chef, Vagrant, Docker & Co | |
# | |
# Based on: https://github.com/felixrieseberg/windows-development-environment | |
# Test-Admin is not available yet, so use... | |
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { | |
Start-Process powershell -ArgumentList "-noprofile -NoExit -file `"$PSCommandPath`"" -Verb RunAs | |
Exit | |
} | |
# http://boxstarter.org/InstallBoxstarter | |
# Installing from the web | |
# From a Administrator PowerShell, if Get-ExecutionPolicy returns Restricted, run: | |
if ((Get-ExecutionPolicy) -eq "Restricted") { | |
Set-ExecutionPolicy Unrestricted -Force | |
} | |
$_boxstarter_path = 'C:\ProgramData\Boxstarter\BoxstarterShell.ps1' | |
if (!(Test-Path $_boxstarter_path)) { | |
. { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force | |
} | |
# Then run: Boxstarter Shell as an Administrator | |
$cwd = "$(Get-Location)" | |
. $_boxstarter_path | |
cd "$cwd" | |
# Copy: Microsoft.PowerShell_profile.ps1 file to $env:userprofile\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 | |
# To install, run from Adinistrator: Boxstarter shell | |
# C:\path\to\this\file\boxstarter.ps1 | |
# Or, open up a PowerShell as Administrator, and run: | |
# START http://boxstarter.org/package/nr/url?https://gist.github.com/jeebak/8064d35757c99b0cd507 | |
# Logs: C:\ProgramData\chocolatey\logs\chocolatey.log | |
# Configure Windows (Boxstarter.WinConfig cmdlets) | |
Set-WindowsExplorerOptions ` | |
-EnableShowHiddenFilesFoldersDrives ` | |
-EnableShowProtectedOSFiles ` | |
-EnableShowFileExtensions ` | |
-EnableShowFullPathInTitleBar ` | |
-DisableOpenFileExplorerToQuickAccess ` | |
-DisableShowRecentFilesInQuickAccess ` | |
-DisableShowFrequentFoldersInQuickAccess | |
Update-ExecutionPolicy Unrestricted | |
# Install chocolatey | |
if (!(Test-Path 'C:\ProgramData\chocolatey\bin\choco.exe')) { | |
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) | |
} | |
# TODO: | |
# http://www.alexdresko.com/2014/12/22/automatically-generating-a-chocolatey-install-script/ | |
# https://www.microsoft.com/web/downloads/platform.aspx | |
# test for this (choco list --source windowsfeatures) | |
cinst -y Microsoft-Hyper-V-All -source windowsFeatures | |
# https://www.microsoft.com/en-us/download/details.aspx?id=55106 | |
# Linux Integration Services | |
# Seed an associative array of all locally installed chocolatey packages | |
$_installed_packages = @{} | |
choco list --limitoutput --localonly | % { | |
$line = $_.split('|') | |
$_installed_packages[$line[0].ToLower()] = $line[1] | |
} | |
function _cinst { | |
param([string] $package) | |
if (!$_installed_packages[$package.ToLower()]) { | |
Write-Host "Installing: $package" | |
cinst -y "$package" | |
} | |
else { | |
Write-Host "Already installed: $package" | |
} | |
} | |
# Seed a string variable with all locally installed PowerShell Gallery modules | |
# Posh-Git | |
$_installed_modules = Get-InstalledModule | |
function _Install-Module { | |
param([string] $module) | |
if ($_installed_modules -match "\b$module\b") { | |
Write-Host "Already installed: $module" | |
} | |
else { | |
Write-Host "Installing: $module" | |
Install-Module $module -Force | |
} | |
} | |
# Packages | |
# Gow | |
_cinst microsoft-windows-terminal | |
#cinst powertoys | |
# Git | |
_cinst git.install # cmder contain: %CMDER_ROOT%\vendor\git-for-windows\ but... | |
_cinst poshgit # git.install is a dependency | |
_cinst git-credential-manager-for-windows # git.install is a dependency | |
#cinst github | |
# Editors | |
# No SublimeText3, atom, or markdownpad2. Using... | |
#cinst -y typora --pre | |
#cinst visualstudiocode | |
_cinst vscodium | |
# w/ vim keybindings | |
_cinst vim # for use under Powershell (there is no "fg" when suspending. Use "exit") | |
# Node, npm | |
# nodejs.install | |
# | |
# Node, npm | |
# nodejs.install | |
# npm install -g npm-windows-upgrade | |
# | |
# Ruby, Go, Python | |
# ruby | |
# ruby.devkit | |
# | |
# golang | |
# | |
# python | |
# pip | |
# | |
# DevOps Stuff | |
# Hyper-V, either/or? | |
# http://www.hanselman.com/blog/SwitchEasilyBetweenVirtualBoxAndHyperVWithABCDEditBootEntryInWindows81.aspx | |
_cinst virtualbox | |
_cinst virtualbox.extensionpack | |
_cinst vagrant | |
_cinst docker-for-windows | |
_cinst wsl | |
_cinst wsl-ubuntu-2004 | |
#cinst docker | |
#cinst docker-machine | |
#cinst docker-compose | |
if (Test-PendingReboot) { Invoke-Reboot } | |
# Basics | |
_cinst GoogleChrome | |
_cinst sysinternals | |
# DotNet3.5 | |
# DotNet4.0 -- not needed on windows 8 | |
# DotNet4.5 -- not needed on windows 10 | |
# PowerShell -- not needed on windows 10 | |
if (Test-PendingReboot) { Invoke-Reboot } | |
# ansicon | |
# babun # Obviated by wsl | |
# cmder # Obviated by wsl | |
# f.lux # Using (currently newer) beta version instead (manually installed) | |
# sharpkeys # Elminated the need for this with this AHK scriptlet: https://superuser.com/a/581988 | |
# ... but would be useful on Macs re: cmd/option keys | |
# There is no touchcursor package: http://martin-stone.github.io/touchcursor/download.html | |
# using custom AutoHotKey script now | |
#cinst acrylic-dns-proxy # Causes problems with wsl | |
_cinst autohotkey.install | |
_cinst clipjump | |
#cinst brave | |
_cinst cshell | |
_cinst cyberduck | |
_cinst fiddler | |
_cinst firefox | |
_cinst greenshot | |
_cinst linqpad | |
_cinst malwarebytes | |
_cinst mpv | |
# https://chocolatey.org/packages/openssh | |
# vs. https://docs.microsoft.com/en-us/windows/uwp/get-started/enable-your-device-for-development | |
choco install -y openssh -params '"/SSHServerFeature"' | |
_cinst paint.net | |
_cinst pasteboard | |
#cinst phpstorm | |
#cinst quicktime | |
_cinst rsync | |
_cinst slack | |
_cinst tor-browser | |
_cinst tortoisegit | |
_cinst webpicmd | |
_cinst windirstat | |
_cinst wireshark | |
# CLI | |
_cinst awscli | |
_cinst bat | |
_cinst jq | |
_cinst pstools | |
_cinst youtube-dl | |
# bitsadmin is deprecated | |
# PowerShell: Invoke-WebRequest -Outfile index.html http://foo.com | |
_cinst curl | |
_cinst wget | |
#cinst wox | |
# Using the PortableApps version of these in OneDrive instead | |
# 7zip.install | |
# cpu-z | |
# ditto # Was using AHK script to map Tab as Alt/Ctrl/Shift as "Hyper" key on hold, Tab on tap, now using clipjump | |
# gimp | |
# putty | |
# sumatrapdf | |
# vlc | |
# winmerge | |
# Meh | |
# bginfo | |
# Pinning Things/File Association (These are Chocolatey functions, not Boxstarter functions) | |
# Install-ChocolateyPinnedTaskBarItem "$env:programfiles\Google\Chrome\Application\chrome.exe" | |
# Install-ChocolateyFileAssociation ".txt" "${env:ProgramFiles(x86)}\Microsoft VS Code\Code.exe" | |
# Visual Studio 2015 (Holy crap! This takes forever!!!) | |
# visualstudio2015community | |
# visualstudio2017community # (?) | |
# if (Test-PendingReboot) { Invoke-Reboot } | |
# https://gist.github.com/dmangiarelli/1a0ae107aaa5c478c51e | |
# How to setup Git for Windows | |
# https://stackoverflow.com/questions/9701840/how-to-create-a-shortcut-using-powershell | |
$WshShell = New-Object -comObject WScript.Shell | |
$Shortcut = $WshShell.CreateShortcut("$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\pageant.lnk") | |
$ppks = $env:USERPROFILE + "\.ssh\*.ppk" | |
$keys = [string[]](Get-ChildItem -Path ($ppks) -Recurse) | |
$Shortcut.TargetPath = '"C:\Program Files\TortoiseGit\bin\pageant.exe"' | |
$Shortcut.Arguments = ($keys -join " ") | |
$Shortcut.Save() | |
# Set System Environment Variable: | |
[Environment]::SetEnvironmentVariable("GIT_SSH", "C:\Program Files\TortoiseGit\bin\TortoiseGitPlink.exe", "Machine") | |
# http://techness.co.uk/2014/08/17/installing-dig-on-windows-8-1/ | |
$_bind_path = "$env:USERPROFILE\OneDrive\Applications\BIND9.10.6.x64" # dig, host, nslookup (Update PATH) | |
if ((Test-Path $_bind_path) -and ! [Environment]::GetEnvironmentVariable('Path', 'Machine') -match [regex]::Escape($_bind_path)) { | |
[Environment]::SetEnvironmentVariable("Path", "${_bind_path};${env:Path}", "Machine") | |
} | |
# PowerShell Gallery | |
_Install-Module posh-docker # https://www.powershellgallery.com/packages/posh-docker/0.0.2 | |
# https://github.com/samneirinck/posh-docker | |
if (-Not (Test-Path $PROFILE)) { | |
New-Item $PROFILE -Type File -Force | |
} | |
if (-Not (Get-Content $PROFILE | % { $_ -match 'Import-Module posh-docker' }) -contains $true) { | |
Add-Content $PROFILE "`nImport-Module posh-docker" | |
} | |
_Install-Module Posh-Git # https://www.powershellgallery.com/packages/Posh-Git/0.7.1 | |
# Functions: Invoke-NullCoalescing Add-PoshGitToProfile Write-GitStatus Write-Prompt Write-VcsStatus Get-GitBranch Get-GitStatus Enable-GitColors Get-GitDirectory TabExpansion Get-AliasPattern Get-SshAgent Start-SshAgent Stop-SshAgent Add-SshKey Get-SshPath Update-AllBranches tgit | |
# https://github.com/dahlbyk/posh-git | |
_Install-Module Posh-SSH # https://www.powershellgallery.com/packages/Posh-SSH/1.7.7 | |
# Cmdlets: Get-SCPFile Get-SCPFolder Get-SFTPFile Set-SFTPFile New-SFTPSession New-SSHSession Set-SCPFile Set-SCPFolder | |
# Functions: Get-SSHSession Remove-SSHSession Invoke-SSHCommand Get-PoshSSHModVersion Invoke-SSHCommandStream New-SSHShellStream Invoke-SSHStreamExpectAction Invoke-SSHStreamExpectSecureAction Get-SSHTrustedHost New-SSHTrustedHost Remove-SSHTrustedHost Get-SFTPSession Remove-SFTPSession Get-SFTPChildItem Test-SFTPPath Remove-SFTPItem Set-SFTPLocation Get-SFTPLocation Rename-SFTPFile Get-SFTPPathAttribute Set-SFTPPathAttribute New-SFTPSymlink Get-SFTPContent Set-SFTPContent New-SFTPFileStream New-SFTPItem | |
# https://github.com/darkoperator/Posh-SSH | |
#Install-Module PSReadline # https://www.powershellgallery.com/packages/PSReadline/1.2 | |
# Cmdlets: Get-PSReadlineKeyHandler Set-PSReadlineKeyHandler Remove-PSReadlineKeyHandler Get-PSReadlineOption Set-PSReadlineOption | |
# Functions: PSConsoleHostReadline | |
# https://www.powershellgallery.com/packages/PSReadline/1.2/Content/SamplePSReadlineProfile.ps1 | |
_Install-Module oh-my-posh # https://www.powershellgallery.com/packages/oh-my-posh/2.0.111 | |
# Functions: Show-Colors Show-ThemeColors Set-Theme Get-VCSStatus Get-VcsInfo Get-Drive Get-ShortPath Get-FullPath Set-CursorForRightBlockWrite Save-CursorPosition Pop-CursorPosition Set-CursorUp Test-VirtualEnv Get-VirtualEnvName | |
# https://github.com/JanJoris/oh-my-posh | |
# Set-Theme darkblood | |
# Show-Colors | |
# $ThemeSettings | |
# $GitPromptSettings | |
# Let's get Updates, too | |
# Install-WindowsUpdate -acceptEula | |
# http://mikefrobbins.com/2016/01/14/powershell-script-module-design-placing-functions-directly-in-the-psm1-file-versus-dot-sourcing-separate-ps1-files/ | |
# Subcommands | |
# https://github.com/lukesampson/scoop | |
# https://signalvnoise.com/posts/3264-automating-with-convention-introducing-sub | |
# https://github.com/basecamp/sub#readme | |
if (Test-PendingReboot) { Invoke-Reboot } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! A slipstream for Windows