Skip to content

Instantly share code, notes, and snippets.

@gatesvp
Created February 16, 2011 00:00
Show Gist options
  • Select an option

  • Save gatesvp/828557 to your computer and use it in GitHub Desktop.

Select an option

Save gatesvp/828557 to your computer and use it in GitHub Desktop.
easy powershell aliases
function df {
$colItems = Get-wmiObject -class "Win32_LogicalDisk" -namespace "root\CIMV2" `
-computername localhost
foreach ($objItem in $colItems) {
write $objItem.DeviceID $objItem.Description $objItem.FileSystem `
($objItem.Size / 1GB).ToString("f3") ($objItem.FreeSpace / 1GB).ToString("f3")
}
}
function LL
{
param ($dir = ".", $all = $false)
$origFg = $host.ui.rawui.foregroundColor
if ( $all ) { $toList = ls -force $dir }
else { $toList = ls $dir }
foreach ($Item in $toList)
{
Switch ($Item.Extension)
{
".Exe" {$host.ui.rawui.foregroundColor = "Yellow"}
".cmd" {$host.ui.rawui.foregroundColor = "Red"}
".msh" {$host.ui.rawui.foregroundColor = "Red"}
".vbs" {$host.ui.rawui.foregroundColor = "Red"}
Default {$host.ui.rawui.foregroundColor = $origFg}
}
if ($item.Mode.StartsWith("d")) {$host.ui.rawui.foregroundColor = "Green"}
$item
}
$host.ui.rawui.foregroundColor = $origFg
}
Set-Alias -Name n -Value 'C:\Program Files\Notepad++\notepad++.exe'
Set-Alias -Name excel -Value 'C:\Program Files\Microsoft Office\Office12\EXCEL.EXE'
Set-Alias -Name zip -Value 'C:\Program Files\7-Zip\7za.exe'
Set-Alias -Name grep -Value Select-String
Set-Alias -Name puts -Value Write-Host
Set-Alias -Name clip -Value Out-Clipboard # Needs PSCX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment