Skip to content

Instantly share code, notes, and snippets.

View mdgrs-mei's full-sized avatar

mdgrs mdgrs-mei

View GitHub Profile
@mdgrs-mei
mdgrs-mei / Matchinfo.Format.ps1xml
Last active September 2, 2023 11:34
Format file to add links to Select-String outputs
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<ViewDefinitions>
<View>
<Name>MatchInfo</Name>
<ViewSelectedBy>
<TypeName>Microsoft.PowerShell.Commands.MatchInfo</TypeName>
</ViewSelectedBy>
<CustomControl>
<CustomEntries>
@mdgrs-mei
mdgrs-mei / TerminalSpinner.ps1
Created June 15, 2023 14:43
Show spinner on the Windows Terminal tabs for every command.
$global:originalPSConsoleHostReadLine = $function:global:PSConsoleHostReadLine
$global:originalPrompt = $function:global:Prompt
$function:global:PSConsoleHostReadLine = {
$startProgressIndicator = "`e]9;4;3;50`e\"
$command = $originalPSConsoleHostReadLine.Invoke()
$startProgressIndicator | Write-Host -NoNewLine
$command
}
@mdgrs-mei
mdgrs-mei / MoonSpinner.ps1
Created June 19, 2023 13:47
Show a moon spinner on the tab title using DynamicTitle PowerShell module
#Requires -Modules DynamicTitle
$commandStartJob = Start-DTJobCommandPreExecutionCallback -ScriptBlock {
param($command)
(Get-Date), $command
}
$promptJob = Start-DTJobPromptCallback -ScriptBlock {
(Get-Date)
}
@mdgrs-mei
mdgrs-mei / TerminalCats.ps1
Last active April 22, 2024 11:12
Cats on the terminal titles
#Requires -Modules DynamicTitle
$promptJob = Start-DTJobPromptCallback {
if ($null -eq $script:terminalCatPromptFrame) {
$script:terminalCatPromptFrame = 0
}
$script:terminalCatPromptFrame++
$isInError = $false
if ($Error[0]) {
@mdgrs-mei
mdgrs-mei / ShellIntegration.ps1
Last active November 4, 2024 22:16
Adds escape codes to the prompt for the shell integration
# Reference:
# https://devblogs.microsoft.com/commandline/shell-integration-in-the-windows-terminal/
param
(
[ValidateSet('WindowsTerminal', 'ITerm2')]
[String]$TerminalProgram = 'WindowsTerminal'
)
# Restore hooked functions in case this script is executed accidentally twice