Last active
March 10, 2017 16:49
-
-
Save cbadke/85c983e2b99240ab0ef0 to your computer and use it in GitHub Desktop.
Scripts to automatically configure a bare-bones Windows dev env. To use: iex ((new-object net.webclient).DownloadString('https://gist.githubusercontent.com/cbadke/85c983e2b99240ab0ef0/raw/config-dev-machine.ps1'))
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
#install Chocolatey | |
iex (new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1') | |
#install PsGet | |
iex (new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | |
Install-Module PSReadLine | |
cinst githubforwindows -y | |
cinst gitextensions -y | |
cinst vim -y | |
cinst conemu -y | |
cinst nugetpackageexplorer -y | |
#fetch powershell profile config | |
mkdir -p ~/Documents/WindowsPowerShell | |
curl -Uri 'https://gist.githubusercontent.com/cbadke/85c983e2b99240ab0ef0/raw/profile.ps1' -Outfile ~/Documents/WindowsPowerShell/profile.ps1 | |
#fetch gitconfig | |
curl -Uri 'https://gist.githubusercontent.com/cbadke/790c8e93e4bc200cdca7/raw/.gitconfig' -Outfile ~/.gitconfig | |
#install vim config | |
iex (new-object net.webclient).DownloadString('https://gist.githubusercontent.com/cbadke/fe5f5e16f0e0da2467d5/raw/vim.ps1') | |
#open a new ConEmu hosted PowerShell instance and close the current PowerShell session | |
#note that ConEmu needs to be manually saved at this point to store font/colour setting for future sessions | |
& 'C:\Program Files\ConEmu\ConEmu64.exe' /Font 'Lucida Console' /Size 24 /Palette '<Gamma 1 \(for use with dark monitors\)>' /cmd 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'; exit |
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
$dev = 'D:\git' | |
$envRoot = (Resolve-Path "$(Split-Path -Parent $MyInvocation.MyCommand.Path)\..\") | |
if (test-path "$env:LOCALAPPDATA\GitHub\shell.ps1") { | |
. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1") | |
} | |
if (test-path "$env:github_posh_git\profile.example.ps1") { | |
. (Resolve-Path $env:github_posh_git\profile.example.ps1) | |
} | |
# If Posh-Git environment is defined, load it. | |
if (test-path env:posh_git) { | |
. (Resolve-Path $env:posh_git) | |
} | |
new-alias fsi 'C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\Fsi.exe' | |
new-alias gitx 'gitextensions.exe' | |
new-alias gx 'gitextensions.exe' | |
new-alias open 'explorer.exe' | |
new-alias vi 'vim' | |
new-alias g 'git.exe' | |
remove-item alias:\cd | |
new-alias cdd 'set-location' | |
new-alias which 'where.exe' | |
new-alias npe nugetpackageexplorer | |
if ($host.Name -eq 'ConsoleHost') { | |
if (Get-Module -ListAvailable PSReadline) { | |
Import-Module PSReadline | |
Set-PSReadlineKeyHandler -Key Tab -Function Complete | |
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward | |
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward | |
Set-PSReadlineOption -HistorySearchCursorMovesToEnd | |
} | |
} | |
function prompt { | |
$realLASTEXITCODE = $LASTEXITCODE | |
# Reset color, which can be messed up by Enable-GitColors | |
$Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor | |
$currPath = (get-location).path; | |
$folders = $currPath.split([System.IO.Path]::DirectorySeparatorChar) | |
$count = $folders.length | |
if ($HOME -eq $currPath) { | |
$curFolder = "~" | |
} | |
else { | |
$curFolder = $folders[$folders.length - 1] | |
} | |
Write-VcsStatus | |
Write-Host "[$curFolder]" -nonewline -ForegroundColor Magenta | |
$global:LASTEXITCODE = $realLASTEXITCODE | |
return " " | |
} | |
function cd { | |
param ( | |
[string]$Path, | |
[switch]$PassThru, | |
[switch]$UseTransaction | |
) | |
$x = Set-Location @PsBoundParameters | |
if ($?) { | |
Get-ChildItem | |
} | |
if ($PassThru) { | |
return $x | |
} | |
return | |
} | |
function o { | |
param ( | |
[string]$Path = '.' | |
) | |
explorer $Path | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment