Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-Module Get-ChildItemColor
- if ( -not $env:ConEmuPID ) {
- function global:prompt {
- -join($(
- if (test-isadmin) {"λ "}),"$($env:username.ToUpper()) ►► ")
- }
- }
- else {
- $ColorSuffix = 'm'
- $global:ColorTimestamp = @(
- 15,
- 7,
- 0
- )
- $global:ColorTimestamp = $($global:ColorTimestamp | % {
- -join($_,$ColorSuffix)
- })
- $global:ColorPrompt =@(
- 117,
- 1,
- 3,
- 22,
- 5,
- 20
- )
- $global:ColorPrompt = [System.Collections.ArrayList]$($global:ColorPrompt | % {
- -join($_,$ColorSuffix)
- })
- $TextColor = -join('$F;',15,$ColorSuffix)
- $BackgroundColor = -join('$B;','$($ColorPrompt[$ColorIndex])')
- $SeperatorBase = """$(-join('$B;','$($ColorPrompt[$ColorIndex + 1])'))$(-join('$F;','$($ColorPrompt[$ColorIndex])')){0}"""
- $seperator = [scriptblock]::Create("$SeperatorBase -f ''")
- $ItemBaseString = """$BackgroundColor$TextColor{0}"
- [System.Collections.Generic.List[ScriptBlock]]$Global:TimestampEntries = @(
- {" " * ($Host.UI.RawUI.BufferSize.Width - 29) }
- {"$F;${er}m{0}" -f [char]0xe0b2 }
- {"$F;$($ColorTimestamp[$TimestampIndex])$B;${er}m{0}" -f $(if (@(get-history).Count -gt 0){(get-history)[-1] | % { "{0:c}" -f (new-timespan $_.StartExecutionTime $_.EndExecutionTime)}}else{'00:00:00.0000000'}) }
- {"$F;$($ColorTimestamp[$TimestampIndex])$B;${er}m{0}" -f [char]0xe0b2 }
- {"$F;$($ColorTimestamp[$TimestampIndex])$B;$($ColorTimestamp[$TimestampIndex - 1]){0}" -f $(get-date -format "hh:mm:ss tt") }
- )
- [System.Collections.Generic.List[ScriptBlock]]$Global:PromptEntries = @(
- "$ItemBaseString"" -f `$('{0:d4}' -f `$MyInvocation.HistoryId)",
- "$ItemBaseString"" -f `$([char]5122)",
- "$ItemBaseString"" -f `$(`$env:username.ToUpper())",
- "$ItemBaseString"" -f `$(if(`$pushd = (Get-Location -Stack).count) { ""`$([char]187)"" + `$pushd })",
- "$ItemBaseString"" -f `$(`$pwd.Drive.Name)",
- "$ItemBaseString`$E[0m"" -f `$(Split-Path `$pwd -leaf)"
- ) | %{[scriptblock]::Create($_);$seperator}
- $Global:PromptEntries[-1] = { "$F;20m{0} $E[0m" -f $([char]0xe0b0) }
- if( -not ( Test-IsAdmin )) {
- $Global:PromptEntries.RemoveRange(2,2)
- $ColorPrompt.RemoveAt(1)
- }
- function global:prompt {
- $global:er = if ($?){22}else{1}
- $E = "$([char]27)"
- $F = "$E[38;5"
- $B = "$E[48;5"
- -join(
- (
- -join$(
- 0..($Global:TimestampEntries.Count - 1) | %{
- $TimestampIndex = $_ - 2
- ($Global:TimestampEntries[$_].Invoke())
- }
- )
- ),
- (
- -join$(
- 0..($Global:PromptEntries.Count - 1) | %{
- $ColorIndex = [math]::Floor($_/2)
- ($Global:PromptEntries[$_].Invoke())
- }
- )
- )
- )
- }
- }
- Import-Module Get-ChildItemColor
- Set-Alias l Get-ChildItemColor -option AllScope
- Set-Alias ls Get-ChildItemColorFormatWide -option AllScope
- Set-Alias dir Get-ChildItemColor -option AllScope -Force
Add Comment
Please, Sign In to add comment