Last active
August 29, 2015 14:12
-
-
Save dan-turner/d8cade545642e27982a9 to your computer and use it in GitHub Desktop.
Powershell Profile
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
# Load posh-git example profile | |
. $env:USERPROFILE'\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1' | |
# Set environment variables for Visual Studio Command Prompt | |
pushd 'c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC' | |
cmd /c "vcvarsall.bat&set" | | |
foreach { | |
if ($_ -match "=") { | |
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])" | |
} | |
} | |
popd | |
# Setup environment vars | |
# $env:PATH += ";SomeTool" | |
function Cntlm-Start { | |
$cn = Get-Process cntlm -ErrorAction SilentlyContinue | |
if($cn -eq $null) { | |
Start-Process "C:\Program Files (x86)\Cntlm\cntlm.exe" "-I -f" | |
$env:HTTP_PROXY = "http://localhost:3128" | |
$env:HTTPS_PROXY = "http://localhost:3128" | |
netsh winhttp set proxy localhost:3128 | |
} | |
} | |
function Cntlm-Stop { | |
$cn = Get-Process cntlm -ErrorAction SilentlyContinue | |
if($cn -ne $null) { | |
Stop-Process -Name cntlm | |
$env:HTTP_PROXY = "" | |
$env:HTTPS_PROXY = "" | |
} | |
} | |
function LockHunter { | |
& "C:\Program Files\LockHunter\LockHunter.exe" $pwd | |
} | |
function Get-WebClient { | |
$wc = New-Object Net.WebClient | |
$wc.UseDefaultCredentials = $true | |
$wc.Proxy.Credentials = $wc.Credentials | |
$wc | |
} | |
function touch($file) { "" | Out-File $file -Encoding ASCII } | |
function Find-Solution($path) { | |
if(!$path) { | |
$path = Get-Location | |
} | |
$sln = Get-ChildItem -Path $path -Recurse -Include "*.sln" | % { $_.FullName } | |
if($sln.Count -eq 1) { | |
return $sln | |
} | |
elseif ($sln.Count -gt 1) { | |
return $sln | Out-GridView -PassThru -Title "Choose VS solution to open..." | |
} | |
return $null; | |
} | |
function Open-Solution($sln) { | |
if(!$sln) { | |
$sln = Find-Solution | |
} | |
$sln | % { &'devenv.exe' $_ } | |
} | |
function Start-Powershell { | |
param( | |
[switch] $AsAdmin) | |
if ($AsAdmin) { | |
Start-Process 'powershell' -Verb RunAs | |
} | |
else { | |
Start-Process 'powershell' | |
} | |
} | |
function Generate-CryptoKey($length) { | |
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create() | |
$bytes = New-Object System.Byte[]($length / 8) | |
$rng.GetBytes($bytes) | |
return [Convert]::ToBase64String($bytes) | |
} | |
# Setup aliases | |
Set-Alias subl 'C:\Program Files\Sublime Text 3\sublime_text.exe' | |
Set-Alias vs 'Open-Solution' | |
Set-Alias lh 'LockHunter' | |
Set-Alias pshell 'Start-Powershell' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment