Created
August 10, 2012 22:10
-
-
Save togakangaroo/3318552 to your computer and use it in GitHub Desktop.
My 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
New-PSDrive HOST -PSProvider FileSystem -Root \\VBOXSVR\georgemauer | |
$tempDir = ([system.io.path]::GetTempPath()) | |
function edit | |
{ | |
param( [Parameter(ValueFromPipeline=$true,Position=0)] $file ) | |
begin { set-alias EDITOR 'W:\tools\sublime_text.bat' } | |
process { EDITOR $file } | |
} | |
function Coalesce-Args { | |
(@($args | ?{$_}) + $null)[0] | |
} | |
Set-Alias ?? Coalesce-Args | |
Set-Alias nuget W:\tools\NuGet.exe | |
set-alias hgworkbench 'C:\Program Files\TortoiseHg\thg.exe' | |
set-alias coffee W:\tools\CoffeeSharp\Coffee.exe | |
function Find-File([string]$pattern="*", $startAt=".") { | |
return Get-ChildItem $startAt -Recurse -Include $pattern | |
} | |
function Find-InFile([string]$searchFor=1, $filePattern="*", $startAt=".") { | |
$found = Find-File -pattern $filePattern -startAt $startAt | Select-String $searchFor | |
if($found -eq $null) { | |
Write-Host "No files found" | |
return | |
} | |
if($found.Count) { # There is more than one | |
do { | |
Write-Host "Please select file (Ctrl+C to quit)" | |
for($i=0;$i -lt $found.Count;$i=$i+1) { Write-Host "($i) - $($found[$i])" } | |
$idx = Read-Host | |
$selected = $found[$idx] | |
}until($selected) | |
} | |
else { $selected = $found } | |
edit "$($selected.Path):$($selected.LineNumber)" | |
} | |
function Open-CurrentVsd { | |
pushd . | |
cd '\\VBOXSVR\gmauer\Dropbox\Preso Builder\Bill Manager' | |
$curr = ls 'BM*.vsd' | sort LastWriteTime -Descending | select -First 1 | |
#cp $curr c:\temp | |
#cd c:\temp | |
#ii $curr.Name | |
ii $curr | |
popd | |
} | |
function Open-Solution([string]$path = ".") { | |
$sln_files = Get-ChildItem $path -Include *.sln -Recurse | |
if($sln_files -eq $null) { | |
Write-Host "No Solution file found" | |
return | |
} | |
if($sln_files.Count) { # There is more than one | |
do { | |
Write-Host "Please select file (or Ctrl+C to quit)" | |
for($i=0;$i -lt $sln_files.Count;$i=$i+1) { Write-Host "($i) - $($sln_files[$i])" } | |
$idx = Read-Host | |
$sln = $sln_files[$idx] | |
}until($sln) | |
} | |
else { $sln = $sln_files } | |
Invoke-Item $sln | |
} | |
function Start-Cassini([string]$physical_path=((@(Coalesce-Args (Find-File Global.asax).DirectoryName "."))[0]), [int]$port=12372, [switch]$dontOpenBrowser) { | |
$serverLocation = Resolve-Path "C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\WebDev.WebServer40.EXE"; | |
$full_app_path = Resolve-Path $physical_path | |
$url = "http://localhost:$port" | |
&($serverLocation.Path) /port:$port /path:"""$($full_app_path.Path)""" | |
Write-Host "Started $($full_app_path.Path) on $url" | |
Write-Host "Remember you can kill processes with kill -name WebDev*" | |
if($dontOpenBrowser -eq $false) { | |
[System.Diagnostics.Process]::Start($url) | |
} | |
} | |
function Remove-Trash( | |
[Parameter(Position=0, Mandatory=$false)][string]$Drive = "", | |
[switch]$NoConfirmation, | |
[switch]$NoProgressGui, | |
[switch]$NoSound | |
) { | |
add-type @" | |
using System; | |
using System.Runtime.InteropServices; | |
using Microsoft.Win32; | |
namespace recyclebin | |
{ | |
public class Empty | |
{ | |
[DllImport("shell32.dll")] | |
static extern int SHEmptyRecycleBin(IntPtr hWnd, string pszRootPath, uint dwFlags); | |
public static void EmptyTrash(string RootDrive, uint Flags) | |
{ | |
SHEmptyRecycleBin(IntPtr.Zero, RootDrive, Flags); | |
} | |
} | |
} | |
"@ | |
[int]$Flags = 0 | |
if ( $NoConfirmation ) { $Flags = $Flags -bor 1 } | |
if ( $NoProgressGui ) { $Flags = $Flags -bor 2 } | |
if ( $NoSound ) { $Flags = $Flags -bor 4 } | |
[recyclebin.Empty]::EmptyTrash($RootPath, $Flags) | |
} | |
set-alias sudo w:/tools/sudo.ps1 | |
set-alias msbuild C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe | |
################################################################### | |
New-PSDrive PB -PSProvider FileSystem -Root W:\Surge\ErwinPenland\EpDigitalSystems.PresentationViewer\Android\PresentationViewer | |
set-alias adb 'C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe' | |
function Invoke-AsAdmin($file) { | |
sudo powershell (Resolve-Path $file) | |
} | |
function Update-SurgeRepos() { | |
pushd . | |
cd w:/Nen/ | |
hg pull -u | |
cd w:/surge/Surge | |
hg pull -u | |
cd w:/surge/ErwinPenland | |
hg pull -u | |
cd w:/surge/PresentationBuilder | |
hg pull -u | |
popd | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment