├── .gitignore ├── Microsoft.PowerShell_profile.ps1 ├── README.md ├── functions ├── Edit-HostsFile.ps1 ├── Get-Bits.ps1 └── prompt.ps1 └── scripts └── README /.gitignore: -------------------------------------------------------------------------------- 1 | /Modules 2 | -------------------------------------------------------------------------------- /Microsoft.PowerShell_profile.ps1: -------------------------------------------------------------------------------- 1 | ########################################################### 2 | # 3 | # Scott's custom profile 4 | # 5 | ########################################################### 6 | 7 | # ahh yes... this would be so nice if it was a built in variable 8 | $here = Split-Path -Parent $MyInvocation.MyCommand.Path 9 | 10 | # load all script modules available to us 11 | Get-Module -ListAvailable | ? { $_.ModuleType -eq "Script" } | Import-Module 12 | 13 | # function loader 14 | # 15 | # if you want to add functions you can added scripts to your 16 | # powershell profile functions directory or you can inline them 17 | # in this file. Ignoring the dot source of any tests 18 | Resolve-Path $here\functions\*.ps1 | 19 | ? { -not ($_.ProviderPath.Contains(".Tests.")) } | 20 | % { . $_.ProviderPath } 21 | 22 | # inline functions, aliases and variables 23 | function which($name) { Get-Command $name | Select-Object Definition } 24 | function rm-rf($item) { Remove-Item $item -Recurse -Force } 25 | function touch($file) { "" | Out-File $file -Encoding ASCII } 26 | Set-Alias g gvim 27 | $TransientScriptDir = "$here\scripts" 28 | $UserBinDir = "$($env:UserProfile)\bin" 29 | 30 | # PATH update 31 | # 32 | # creates paths to every subdirectory of userprofile\bin 33 | # adds a transient script dir that I use for experiments 34 | $paths = @("$($env:Path)", $TransientScriptDir) 35 | gci $UserBinDir | % { $paths += $_.FullName } 36 | $env:Path = [String]::Join(";", $paths) 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Powershell Profile 2 | ================== 3 | 4 | To install simply run the following in Powershell 5 | 6 |
 7 | git clone git@github.com:scottmuc/poshfiles %USERPROFILE%\Documents\WindowsPowershell
 8 | 
9 | 10 | Features 11 | -------- 12 | 13 | - Creates a pretty prompt 14 | - Imports all Script modules whenever powershell is run 15 | - Sets up your $env:Path so all directories in $env:UserProfile\bin are globally available 16 | - Loaded with some utility functions 17 | -------------------------------------------------------------------------------- /functions/Edit-HostsFile.ps1: -------------------------------------------------------------------------------- 1 | function Edit-HostsFile { 2 | Start-Process -FilePath notepad -ArgumentList "$env:windir\system32\drivers\etc\hosts" 3 | } 4 | 5 | -------------------------------------------------------------------------------- /functions/Get-Bits.ps1: -------------------------------------------------------------------------------- 1 | # found at http://www.gregorystrike.com/2011/01/27/how-to-tell-if-powershell-is-32-bit-or-64-bit/ 2 | function Get-Bits { 3 | Switch ([System.Runtime.InterOpServices.Marshal]::SizeOf([System.IntPtr])) { 4 | 4 { Return "32-bit" } 5 | 8 { Return "64-bit" } 6 | default { Return "Unknown Type" } 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /functions/prompt.ps1: -------------------------------------------------------------------------------- 1 | # prompt customization coming from the following: 2 | # http://winterdom.com/2008/08/mypowershellprompt 3 | function shorten-path([string] $path) { 4 | $loc = $path.Replace($HOME, '~') 5 | # remove prefix for UNC paths 6 | $loc = $loc -replace '^[^:]+::', '' 7 | # make path shorter like tabs in Vim, 8 | # handle paths starting with \\ and . correctly 9 | return ($loc -replace '\\(\.?)([^\\])[^\\]*(?=\\)','\$1$2') 10 | } 11 | 12 | # This is function is called by convention in PowerShell 13 | function prompt { 14 | # our theme 15 | $cdelim = [ConsoleColor]::DarkCyan 16 | $chost = [ConsoleColor]::Green 17 | $cloc = [ConsoleColor]::Cyan 18 | 19 | write-host "$([char]0x0A7) " -n -f $cloc 20 | write-host ([net.dns]::GetHostName()) -n -f $chost 21 | write-host ' {' -n -f $cdelim 22 | write-host (shorten-path (pwd).Path) -n -f $cloc 23 | write-host '}' -n -f $cdelim 24 | 25 | $global:GitStatus = Get-GitStatus 26 | Write-GitStatus $GitStatus 27 | 28 | return '> ' 29 | } 30 | 31 | Enable-GitColors 32 | -------------------------------------------------------------------------------- /scripts/README: -------------------------------------------------------------------------------- 1 | Any scripts in this location will be accessible from anywhere... you've been warned. 2 | --------------------------------------------------------------------------------