Skip to content

Commit 4cc974e

Browse files
authored
Update Microsoft.PowerShell_profile.ps1
1 parent 0a31e36 commit 4cc974e

File tree

1 file changed

+71
-19
lines changed

1 file changed

+71
-19
lines changed

Microsoft.PowerShell_profile.ps1

+71-19
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ function prompt {
1313
$curPath = '...' + $curPath.SubString($curPath.Length - $maxPathLength + 3)
1414
}
1515

16-
Write-Host "$time [$env:COMPUTERNAME] $curPath" -NoNewline
16+
#Write-Host "$time [$env:COMPUTERNAME] $curPath" -NoNewline
17+
Write-Host "[$env:COMPUTERNAME] $curPath" -NoNewline
1718
Write-VcsStatus
1819
$LASTEXITCODE = $origLastExitCode
1920
"$('>' * ($nestedPromptLevel + 1)) "
@@ -37,26 +38,10 @@ else {
3738
Import-Module -Name posh-git
3839
}
3940

40-
# Chocolatey profile
41-
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
42-
if (Test-Path($ChocolateyProfile)) {
43-
Import-Module "$ChocolateyProfile"
44-
}
45-
46-
<#
47-
function prompt {
48-
$time = (Get-DAte).ToShortTimeString()
49-
"$time [$env:COMPUTERNAME] $(Get-Location)> "
50-
}
51-
52-
#>
53-
54-
$global:GitPromptSettings.BeforeText = '['
55-
$global:GitPromptSettings.AfterText = ']'
41+
#$global:GitPromptSettings.BeforeText = '['
42+
#$global:GitPromptSettings.AfterText = ']'
5643
$global:GitPromptSettings.DefaultPromptAbbreviateHomeDirectory = $true
5744

58-
Set-PSReadLineOption -HistoryNoDuplicates -ShowToolTips
59-
6045
# derived from http://www.checkyourlogs.net/?p=38333
6146
# if password is a passphrase (>=14 chars, return complexity = true)
6247
# if password otherwise has 3 of the 4 criteria of MS AD complexity requirements, return true
@@ -380,6 +365,73 @@ function global:Format-WslArgument([string]$arg, [bool]$interactive) {
380365
return $arg
381366
}
382367

368+
function Get-Base64RegularExpression {
369+
370+
## Get-Base64RegularExpression.ps1
371+
## Get a regular expression that can be used to search for content that has been
372+
## Base-64 encoded
373+
param(
374+
## The value that we would like to search for in Base64 encoded content
375+
[Parameter(Mandatory)]
376+
$Value
377+
)
378+
379+
## Holds the various byte representations of what we're searching for
380+
$byteRepresentations = @()
381+
382+
## If we got a string, look for the Unicode and ASCII representations of the string
383+
if($Value -is [String])
384+
{
385+
$byteRepresentations +=
386+
[System.Text.Encoding]::Unicode.GetBytes($Value),
387+
[System.Text.Encoding]::ASCII.GetBytes($Value)
388+
}
389+
390+
## If it was a byte array directly, look for the byte representations
391+
if($Value -is [byte[]])
392+
{
393+
$byteRepresentations += ,$Value
394+
}
395+
396+
## Find the safe searchable sequences for each Base64 representation of input bytes
397+
$base64sequences = foreach($bytes in $byteRepresentations)
398+
{
399+
## Offset 0. Sits on a 3-byte boundary so we can trust the leading characters.
400+
$offset0 = [Convert]::ToBase64String($bytes)
401+
402+
## Offset 1. Has one byte from preceeding content, so we need to throw away the
403+
## first 2 leading characters
404+
$offset1 = [Convert]::ToBase64String( (New-Object 'Byte[]' 1) + $bytes ).Substring(2)
405+
406+
## Offset 2. Has two bytes from preceeding content, so we need to throw away the
407+
## first 4 leading characters
408+
$offset2 = [Convert]::ToBase64String( (New-Object 'Byte[]' 2) + $bytes ).Substring(4)
409+
410+
## If there is any terminating padding, we must remove the characters mixed with that padding. That
411+
## ends up being the number of equals signs, plus one.
412+
$base64matches = $offset0,$offset1,$offset2 | % {
413+
if($_ -match '(=+)$')
414+
{
415+
$_.Substring(0, $_.Length - ($matches[0].Length + 1))
416+
}
417+
else
418+
{
419+
$_
420+
}
421+
}
422+
423+
$base64matches | ? { $_ }
424+
}
425+
426+
## Output a regular expression for these sequences
427+
"(" + (($base64sequences | Sort-Object -Unique) -join "|") + ")"
428+
429+
}
430+
383431
Import-WslCommand 'awk', 'grep', 'head', 'jq', 'less', 'man', 'sed', 'seq', 'tail', 'vim'
384432

433+
import-module oh-my-posh
434+
import-module terminal-icons
435+
Set-PoshPrompt -Theme ~/Documents/WindowsPowerShell/mdavis.omp.json
436+
385437
Set-Location c:\

0 commit comments

Comments
 (0)