Skip to content

Instantly share code, notes, and snippets.

@maksha
Last active July 25, 2017 07:48
Show Gist options
  • Select an option

  • Save maksha/cff3de229c4a2df201af5ac1bbabbd91 to your computer and use it in GitHub Desktop.

Select an option

Save maksha/cff3de229c4a2df201af5ac1bbabbd91 to your computer and use it in GitHub Desktop.

Revisions

  1. maksha revised this gist Jul 25, 2017. 1 changed file with 7 additions and 17 deletions.
    24 changes: 7 additions & 17 deletions PowerShell_profile.ps1
    Original file line number Diff line number Diff line change
    @@ -1,29 +1,19 @@
    # Run PowerShell as administrator:
    # 0. Set Execution Policy:
    # PS> Set-ExecutionPolicy RemoteSigned
    #
    # 1. Install PsGet (http://psget.net/):
    # PS> (new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | iex
    #
    # 2. Install Posh-Git (https://github.com/dahlbyk/posh-git):
    # PS> Install-Module posh-git

    # As regular user
    # Import module posh-git
    Import-Module -Name posh-git

    # Chocolatey profile
    $ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
    if (Test-Path($ChocolateyProfile)) {
    Import-Module "$ChocolateyProfile"
    }

    # Setup awesome PS prompt
    function Test-Administrator {
    $user = [Security.Principal.WindowsIdentity]::GetCurrent();
    (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
    }

    # Chocolatey profile
    $ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
    if (Test-Path($ChocolateyProfile)) {
    Import-Module "$ChocolateyProfile"
    }

    function prompt {
    $realLASTEXITCODE = $LASTEXITCODE

    @@ -55,4 +45,4 @@ function prompt {
    Write-VcsStatus

    return "> "
    }
    }
  2. maksha revised this gist Dec 23, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion PowerShell_profile.ps1
    Original file line number Diff line number Diff line change
    @@ -55,4 +55,4 @@ function prompt {
    Write-VcsStatus

    return "> "
    }
    }
  3. maksha revised this gist Nov 25, 2016. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion PowerShell_profile.ps1
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,14 @@
    # Run PowerShell as administrator:
    # 0. Set Execution Policy:
    # PS> Set-ExecutionPolicy RemoteSigned
    #
    # 1. Install PsGet (http://psget.net/):
    # PS> (new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | iex
    #
    # 2. Install Posh-Git (https://github.com/dahlbyk/posh-git):
    # PS> Install-Module posh-git

    # As regular user
    # Import module posh-git
    Import-Module -Name posh-git

    @@ -7,7 +18,6 @@ if (Test-Path($ChocolateyProfile)) {
    Import-Module "$ChocolateyProfile"
    }


    # Setup awesome PS prompt
    function Test-Administrator {
    $user = [Security.Principal.WindowsIdentity]::GetCurrent();
  4. maksha created this gist Nov 25, 2016.
    48 changes: 48 additions & 0 deletions PowerShell_profile.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    # Import module posh-git
    Import-Module -Name posh-git

    # Chocolatey profile
    $ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
    if (Test-Path($ChocolateyProfile)) {
    Import-Module "$ChocolateyProfile"
    }


    # Setup awesome PS prompt
    function Test-Administrator {
    $user = [Security.Principal.WindowsIdentity]::GetCurrent();
    (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
    }

    function prompt {
    $realLASTEXITCODE = $LASTEXITCODE

    Write-Host

    # Reset color, which can be messed up by Enable-GitColors
    $Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor

    if (Test-Administrator) { # Use different username if elevated
    Write-Host "(Elevated) " -NoNewline -ForegroundColor White
    }

    Write-Host " $ENV:USERNAME " -NoNewline -ForegroundColor White -BackgroundColor DarkGray

    if ($s -ne $null) { # color for PSSessions
    Write-Host " (`$s: " -NoNewline -ForegroundColor DarkGray
    Write-Host "$($s.Name)" -NoNewline -ForegroundColor Yellow
    Write-Host ") " -NoNewline -ForegroundColor DarkGray
    }

    Write-Host "" $($(Get-Location) -replace ($env:USERPROFILE).Replace('\','\\'), "~") "" -NoNewline -ForegroundColor Black -BackgroundColor Gray

    $global:LASTEXITCODE = $realLASTEXITCODE

    Write-Host

    Write-Host " " ($([char]0x2192)) " " -NoNewline -BackgroundColor DarkGray

    Write-VcsStatus

    return "> "
    }