configure startup.

c:/users/mkhan/documents/windowspowershell/profile.ps1

 1   # Load posh-git module from current directory
 2  Import-Module d:\scripts\posh-git
 3 
 4      # Set up a simple prompt, adding the git prompt parts inside git repos
 5  function prompt {
 6      $host.UI.RawUi.WindowTitle = get_current_folder
 7      return write_prompt(get_unix_style_path);
 8  }
 9  function get_current_folder() {
10      $pathbits = ([string]$pwd).split("\", [System.StringSplitOptions]::RemoveEmptyEntries)
11      if($pathbits.length -eq 1) {
12        return   $pathbits[0] + "\";
13      } 
14      return   $pathbits[$pathbits.length - 1]
15  }
16  function get_unix_style_path() {
17      return '/' + ([string]$pwd).replace('\','/').replace(':','').tolower()
18  }
19  function write_prompt($path) {
20      Write-Host( ($env:username + '@' + [System.Environment]::MachineName + ' ' + $path).tolower() ) -foregroundcolor Green
21          
22      $Global:GitStatus = Get-GitStatus
23      Write-GitStatus $GitStatus
24      return "$ " 
25  }
26 
27  if(-not (Test-Path Function:\DefaultTabExpansion)) {
28      Rename-Item Function:\TabExpansion DefaultTabExpansion
29  }
30 
31      # Set up tab expansion and include git expansion
32  function TabExpansion($line, $lastWord) {
33      $lastBlock = [regex]::Split($line, '[|;]')[-1]
34      
35      switch -regex ($lastBlock) {
36          # Execute git tab completion for all git-related commands
37          'git (.*)' { GitTabExpansion $lastBlock }
38          # Fall back on existing tab expansion
39          default { DefaultTabExpansion $line $lastWord }
40      }
41  }
42 
43  Enable-GitColors
comments powered by Disqus