configure startup.
c:/users/mkhan/documents/windowspowershell/profile.ps1
# Load posh-git module from current directory
Import-Module d:\scripts\posh-git
# Set up a simple prompt, adding the git prompt parts inside git repos
function prompt {
$host.UI.RawUi.WindowTitle = get_current_folder
return write_prompt(get_unix_style_path);
}
function get_current_folder() {
$pathbits = ([string]$pwd).split("\", [System.StringSplitOptions]::RemoveEmptyEntries)
if($pathbits.length -eq 1) {
return $pathbits[0] + "\";
}
return $pathbits[$pathbits.length - 1]
}
function get_unix_style_path() {
return '/' + ([string]$pwd).replace('\','/').replace(':','').tolower()
}
function write_prompt($path) {
Write-Host( ($env:username + '@' + [System.Environment]::MachineName + ' ' + $path).tolower() ) -foregroundcolor Green
$Global:GitStatus = Get-GitStatus
Write-GitStatus $GitStatus
return "$ "
}
if(-not (Test-Path Function:\DefaultTabExpansion)) {
Rename-Item Function:\TabExpansion DefaultTabExpansion
}
# Set up tab expansion and include git expansion
function TabExpansion($line, $lastWord) {
$lastBlock = [regex]::Split($line, '[|;]')[-1]
switch -regex ($lastBlock) {
# Execute git tab completion for all git-related commands
'git (.*)' { GitTabExpansion $lastBlock }
# Fall back on existing tab expansion
default { DefaultTabExpansion $line $lastWord }
}
}
Enable-GitColors