Skip to content

Instantly share code, notes, and snippets.

@asears
Created November 10, 2020 12:00
Show Gist options
  • Select an option

  • Save asears/95d5590962b11edd0f3fa2d7b1d98f7b to your computer and use it in GitHub Desktop.

Select an option

Save asears/95d5590962b11edd0f3fa2d7b1d98f7b to your computer and use it in GitHub Desktop.
Microsoft Powershell Core Profile
<#
.SYNOPSIS
Powershell Profile
.DESCRIPTION
Powershell Profile
.PARAMETER
None
.INPUTS
None
.OUTPUTS
None
.NOTES
Version: 1.1
Author: Andrew Sears
Create Date: December 4, 2019
Update Date: November 10, 2020
Purpose/Change: Remove width constraint of tables
.EXAMPLE
Test-Path $profile
New-Item -path $profile -type file –force
#>
#set-location c:
#$Shell.WindowTitle="Powershell"
<#$Shell = $Host.UI.RawUI
$size = $Shell.WindowSize
$size.width=70
$size.height=25
$Shell.WindowSize = $size
$size = $Shell.BufferSize
$size.width=70
$size.height=5000
$Shell.BufferSize = $size
$shell.BackgroundColor = "Gray"
$shell.ForegroundColor = "Black"
#>
#Start-Transcript -Append
#function Close-Powershell { if ($Error.Count -gt 0) { $Error | Out-File c:\powershell\errors$YYYYMMDD.txt -Append } }
#Stop-Transcript
#exit
new-item alias:np -value C:\Windows\System32\notepad.exe
new-item alias:k -value C:\ProgramData\chocolatey\bin\kubectl.exe
Function grok
{
param(
$Command
)
Get-Help $Command -Full
}
function Find
{
param(
[string]$Text,
[string]$Filter = '*.*',
[switch]$CaseSensitive
)
Get-ChildItem $Filter -Recurse | Select-String $Text -SimpleMatch -CaseSensitive:$CaseSensitive
}
function Stack
{
Get-PSCallStack | Select-Object Command, Location, Position, Arguments
}
if ($Host.Name -eq 'ConsoleHost')
{
Import-Module PSReadline
# differentiate verbose from warnings!
$privData = (Get-Host).PrivateData
$privData.VerboseForegroundColor = "cyan"
}
elseif ($Host.Name -like '*ISE Host')
{
Start-Steroids
Import-Module PsIseProjectExplorer
}
if (!$env:github_shell)
{
# not sure why, but this fails in a git-flavored host
#Add-PSSnapin Microsoft.TeamFoundation.PowerShell
}
# https://tommymaynard.com/linux-prompt-on-windows-part-1-2016/
# Install-Script -Name Switch-Prompt -Scope CurrentUser
(Get-PSProvider -PSProvider FileSystem).Home = $env:USERPROFILE
Function Prompt {
If ([bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).Groups -match 'S-1-5-32-544')) {
$Symbol = '#'
} Else {
$Symbol = '$'
}
If ($PWD.Path -eq $env:USERPROFILE) {
$Location = '~'
} ElseIf ($PWD.Path -like "*$env:USERPROFILE*") {
$Location = $PWD.Path -replace ($env:USERPROFILE -replace '\\','\\'),'~' -replace '\\','/'
} Else {
$Location = "$(($PWD.Path -replace '\\','/' -split ':')[-1])"
}
$Prompt = "$($env:USERNAME.ToLower())@$($env:COMPUTERNAME.ToLower()) $Location $Symbol "
$Host.UI.RawUI.WindowTitle = $Prompt
$Prompt
}
# Set unlimited width $FormatEnumerationLimit = -1 to remove ... in string results
Write-Output "Set FormatEnumerationLimit = -1"
$FormatEnumerationLimit = -1
# Clear-Host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment