Guest User

Untitled

a guest
Jun 20th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. # Import module from previous step
  2. Import-Module -Name posh-git
  3.  
  4. function Test-Administrator {
  5. $user = [Security.Principal.WindowsIdentity]::GetCurrent();
  6. (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
  7. }
  8.  
  9. function prompt {
  10. $realLASTEXITCODE = $LASTEXITCODE
  11.  
  12. Write-Host
  13.  
  14. # Reset color, which can be messed up by Enable-GitColors
  15. #$Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor
  16.  
  17. if (Test-Administrator) {
  18. # Use different username if elevated
  19. Write-Host "(Elevated) " -NoNewline -ForegroundColor White
  20. }
  21.  
  22. if ($s -ne $null) {
  23. # color for PSSessions
  24. Write-Host " (`$s: " -NoNewline -ForegroundColor DarkGray
  25. Write-Host "$($s.Name)" -NoNewline -ForegroundColor Yellow
  26. Write-Host ") " -NoNewline -ForegroundColor DarkGray
  27. Write-Host " : " -NoNewline -ForegroundColor DarkGray
  28. }
  29.  
  30. Write-Host $($(Get-Location) -replace ($env:USERPROFILE).Replace('\', '\\'), "~") -NoNewline -ForegroundColor Blue
  31. Write-Host " : " -NoNewline -ForegroundColor DarkGray
  32. Write-Host (Get-Date -Format G) -NoNewline -ForegroundColor DarkMagenta
  33. Write-Host " : " -NoNewline -ForegroundColor DarkGray
  34.  
  35. $global:LASTEXITCODE = $realLASTEXITCODE
  36. Write-VcsStatus
  37. $command = Get-History -Count 1
  38. Write-Host " Execution Time: $($command.EndExecutionTime - $command.StartExecutionTime)" -NoNewline -ForegroundColor DarkGray
  39. Write-Host ""
  40. return "> "
  41. }
  42.  
  43. New-PSDrive -Name Github -PSProvider FileSystem -Root C:\Repos\Github | Out-Null
  44. New-PSDrive -Name Geberit -PSProvider FileSystem -Root C:\Repos\Geberit | Out-Null
  45. New-PSDrive -Name HIAG -PSProvider FileSystem -Root C:\Repos\HIAG | Out-Null
  46. New-PSDrive -Name itnetX -PSProvider FileSystem -Root C:\Repos\itnetX | Out-Null
  47.  
  48. Set-Alias ls Get-ChildItemColor -option AllScope -Force
  49. Set-Alias dir Get-ChildItemColor -option AllScope -Force
  50.  
  51. Import-Module PSReadLine
  52.  
  53. Set-PSReadLineOption -HistoryNoDuplicates
  54. Set-PSReadLineOption -HistorySearchCursorMovesToEnd
  55. Set-PSReadLineOption -HistorySaveStyle SaveIncrementally
  56. Set-PSReadLineOption -MaximumHistoryCount 4000
  57. # history substring search
  58. Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
  59. Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
  60.  
  61. # Tab completion
  62. Set-PSReadlineKeyHandler -Chord 'Shift+Tab' -Function Complete
  63. Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
  64.  
  65.  
  66. function cddash {
  67. if ($args[0] -eq '-') {
  68. $pwd = $OLDPWD;
  69. } else {
  70. $pwd = $args[0];
  71. }
  72. $tmp = pwd;
  73.  
  74. if ($pwd) {
  75. Set-Location $pwd;
  76. }
  77. Set-Variable -Name OLDPWD -Value $tmp -Scope global;
  78. }
  79.  
  80. Set-Alias -Name cd -value cddash -Option AllScope
  81.  
  82.  
  83. $global:GitPromptSettings.BranchAheadStatusForegroundColor = [ConsoleColor]::Green
Add Comment
Please, Sign In to add comment