Created
February 20, 2024 02:54
-
-
Save Announcement/536e90b0c7bee75fe7a32a72ecd17269 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prompt { | |
$private:Token = "→" | |
Write-Host -NoNewline $Token | |
" " | |
} | |
Invoke-Command { | |
Set-Alias -Name j -Value Join-String | |
Set-Alias -Name cfj -Value ConvertFrom-Json | |
Set-Alias -Name ctj -Value ConvertTo-Json | |
Set-PSReadlineOption -Color @{ | |
"Command" = [ConsoleColor]::Green | |
"Parameter" = [ConsoleColor]::Gray | |
"Operator" = [ConsoleColor]::Magenta | |
"Variable" = [ConsoleColor]::White | |
"String" = [ConsoleColor]::Yellow | |
"Number" = [ConsoleColor]::Blue | |
"Type" = [ConsoleColor]::Cyan | |
"Comment" = [ConsoleColor]::DarkCyan | |
} | |
$PSStyle.FileInfo.Directory = "`e[38;2;255;255;255m" | |
} | |
## | |
## | |
# Set-PSReadLineOption -PredictionSource Plugin | |
# Set-PSReadLineKeyHandler -Key Tab -ScriptBlock { Invoke-FzfTabCompletion } | |
# Set-PsFzfOption -TabExpansion | |
# Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r' | |
# $Env:MAMBA_ROOT_PREFIX = "C:\Users\power\micromambaenv" | |
# $Env:MAMBA_EXE = "C:\Users\power\AppData\Local\micromamba\micromamba.exe" | |
# $private:Flavor = $Catppuccin['Mocha'] | |
# $ENV:FZF_DEFAULT_OPTS = @" | |
# --color=bg+:$($Flavor.Surface0),bg:$($Flavor.Base),spinner:$($Flavor.Rosewater) | |
# --color=hl:$($Flavor.Red),fg:$($Flavor.Text),header:$($Flavor.Red) | |
# --color=info:$($Flavor.Mauve),pointer:$($Flavor.Rosewater),marker:$($Flavor.Rosewater) | |
# --color=fg+:$($Flavor.Text),prompt:$($Flavor.Mauve),hl+:$($Flavor.Red) | |
# --color=border:$($Flavor.Surface2) | |
# "@ | |
# $private:Colors = @{ | |
# # Largely based on the Code Editor style guide | |
# # Emphasis, ListPrediction and ListPredictionSelected are inspired by the Catppuccin fzf theme | |
# # Powershell colours | |
# ContinuationPrompt = $Flavor.Teal.Foreground() | |
# Emphasis = $Flavor.Red.Foreground() | |
# Selection = $Flavor.Surface0.Background() | |
# # PSReadLine prediction colours | |
# InlinePrediction = $Flavor.Overlay0.Foreground() | |
# ListPrediction = $Flavor.Mauve.Foreground() | |
# ListPredictionSelected = $Flavor.Surface0.Background() | |
# # Syntax highlighting | |
# Command = $Flavor.Blue.Foreground() | |
# Comment = $Flavor.Overlay0.Foreground() | |
# Default = $Flavor.Text.Foreground() | |
# Error = $Flavor.Red.Foreground() | |
# Keyword = $Flavor.Mauve.Foreground() | |
# Member = $Flavor.Rosewater.Foreground() | |
# Number = $Flavor.Peach.Foreground() | |
# Operator = $Flavor.Sky.Foreground() | |
# Parameter = $Flavor.Pink.Foreground() | |
# String = $Flavor.Green.Foreground() | |
# Type = $Flavor.Yellow.Foreground() | |
# Variable = $Flavor.Lavender.Foreground() | |
# } | |
# # Set the colours | |
# Set-PSReadLineOption -Colors $Colors | |
# $PSStyle.Formatting.Debug = $Flavor.Sky.Foreground() | |
# $PSStyle.Formatting.Error = $Flavor.Red.Foreground() | |
# $PSStyle.Formatting.ErrorAccent = $Flavor.Blue.Foreground() | |
# $PSStyle.Formatting.FormatAccent = $Flavor.Teal.Foreground() | |
# $PSStyle.Formatting.TableHeader = $Flavor.Rosewater.Foreground() | |
# $PSStyle.Formatting.Verbose = $Flavor.Yellow.Foreground() | |
# $PSStyle.Formatting.Warning = $Flavor.Peach.Foreground() | |
# (& $Env:MAMBA_EXE 'shell' 'hook' -s 'powershell' -p $Env:MAMBA_ROOT_PREFIX) | Out-String | Invoke-Expression | |
# #endregion | |
# micromamba shell hook -s powershell -p $Env:MAMBA_ROOT_PREFIX | Out-String | Invoke-Expression | |
# (& pixi completion --shell powershell) | Out-String | Invoke-Expression | |
# installed rust commands | |
# bat ~\.cargo\.crates.toml | |
# https://github.com/Canop/broot/issues/460#issuecomment-1303005689 | |
# Function br { | |
# $argz = $args -join ' ' | |
# $cmd_file = New-TemporaryFile | |
# $process = Start-Process -FilePath 'broot.exe' ` | |
# -ArgumentList "--outcmd $($cmd_file.FullName) $argz" ` | |
# -NoNewWindow -PassThru -WorkingDirectory $PWD | |
# Wait-Process -InputObject $process #Faster than Start-Process -Wait | |
# If ($process.ExitCode -eq 0) { | |
# $cmd = Get-Content $cmd_file | |
# Remove-Item $cmd_file | |
# If ($null -ne $cmd) { Invoke-Expression -Command $cmd } | |
# } | |
# Else { | |
# Remove-Item $cmd_file | |
# Write-Host "`n" # Newline to tidy up broot unexpected termination | |
# Write-Error "broot.exe exited with error code $($process.ExitCode)" | |
# } | |
# } | |
# #region Smart Insert/Delete | |
# # The next four key handlers are designed to make entering matched quotes | |
# # parens, and braces a nicer experience. I'd like to include functions | |
# # in the module that do this, but this implementation still isn't as smart | |
# # as ReSharper, so I'm just providing it as a sample. | |
# Set-PSReadLineKeyHandler -Key '"', "'" ` | |
# -BriefDescription SmartInsertQuote ` | |
# -LongDescription "Insert paired quotes if not already on a quote" ` | |
# -ScriptBlock { | |
# param($key, $arg) | |
# $quote = $key.KeyChar | |
# $selectionStart = $null | |
# $selectionLength = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetSelectionState([ref]$selectionStart, [ref]$selectionLength) | |
# $line = $null | |
# $cursor = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor) | |
# # If text is selected, just quote it without any smarts | |
# if ($selectionStart -ne -1) { | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Replace($selectionStart, $selectionLength, $quote + $line.SubString($selectionStart, $selectionLength) + $quote) | |
# [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($selectionStart + $selectionLength + 2) | |
# return | |
# } | |
# $ast = $null | |
# $tokens = $null | |
# $parseErrors = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$ast, [ref]$tokens, [ref]$parseErrors, [ref]$null) | |
# function FindToken { | |
# param($tokens, $cursor) | |
# foreach ($token in $tokens) { | |
# if ($cursor -lt $token.Extent.StartOffset) { continue } | |
# if ($cursor -lt $token.Extent.EndOffset) { | |
# $result = $token | |
# $token = $token -as [StringExpandableToken] | |
# if ($token) { | |
# $nested = FindToken $token.NestedTokens $cursor | |
# if ($nested) { $result = $nested } | |
# } | |
# return $result | |
# } | |
# } | |
# return $null | |
# } | |
# $token = FindToken $tokens $cursor | |
# # If we're on or inside a **quoted** string token (so not generic), we need to be smarter | |
# if ($token -is [StringToken] -and $token.Kind -ne [TokenKind]::Generic) { | |
# # If we're at the start of the string, assume we're inserting a new string | |
# if ($token.Extent.StartOffset -eq $cursor) { | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Insert("$quote$quote ") | |
# [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($cursor + 1) | |
# return | |
# } | |
# # If we're at the end of the string, move over the closing quote if present. | |
# if ($token.Extent.EndOffset -eq ($cursor + 1) -and $line[$cursor] -eq $quote) { | |
# [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($cursor + 1) | |
# return | |
# } | |
# } | |
# if ($null -eq $token -or | |
# $token.Kind -eq [TokenKind]::RParen -or $token.Kind -eq [TokenKind]::RCurly -or $token.Kind -eq [TokenKind]::RBracket) { | |
# if ($line[0..$cursor].Where{ $_ -eq $quote }.Count % 2 -eq 1) { | |
# # Odd number of quotes before the cursor, insert a single quote | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Insert($quote) | |
# } | |
# else { | |
# # Insert matching quotes, move cursor to be in between the quotes | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Insert("$quote$quote") | |
# [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($cursor + 1) | |
# } | |
# return | |
# } | |
# # If cursor is at the start of a token, enclose it in quotes. | |
# if ($token.Extent.StartOffset -eq $cursor) { | |
# if ($token.Kind -eq [TokenKind]::Generic -or $token.Kind -eq [TokenKind]::Identifier -or | |
# $token.Kind -eq [TokenKind]::Variable -or $token.TokenFlags.hasFlag([TokenFlags]::Keyword)) { | |
# $end = $token.Extent.EndOffset | |
# $len = $end - $cursor | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Replace($cursor, $len, $quote + $line.SubString($cursor, $len) + $quote) | |
# [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($end + 2) | |
# return | |
# } | |
# } | |
# # We failed to be smart, so just insert a single quote | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Insert($quote) | |
# } | |
# Set-PSReadLineKeyHandler -Key '(', '{', '[' ` | |
# -BriefDescription InsertPairedBraces ` | |
# -LongDescription "Insert matching braces" ` | |
# -ScriptBlock { | |
# param($key, $arg) | |
# $closeChar = switch ($key.KeyChar) { | |
# <#case#> '(' { [char]')'; break } | |
# <#case#> '{' { [char]'}'; break } | |
# <#case#> '[' { [char]']'; break } | |
# } | |
# $selectionStart = $null | |
# $selectionLength = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetSelectionState([ref]$selectionStart, [ref]$selectionLength) | |
# $line = $null | |
# $cursor = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor) | |
# if ($selectionStart -ne -1) { | |
# # Text is selected, wrap it in brackets | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Replace($selectionStart, $selectionLength, $key.KeyChar + $line.SubString($selectionStart, $selectionLength) + $closeChar) | |
# [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($selectionStart + $selectionLength + 2) | |
# } | |
# else { | |
# # No text is selected, insert a pair | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Insert("$($key.KeyChar)$closeChar") | |
# [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($cursor + 1) | |
# } | |
# } | |
# Set-PSReadLineKeyHandler -Key ')', ']', '}' ` | |
# -BriefDescription SmartCloseBraces ` | |
# -LongDescription "Insert closing brace or skip" ` | |
# -ScriptBlock { | |
# param($key, $arg) | |
# $line = $null | |
# $cursor = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor) | |
# if ($line[$cursor] -eq $key.KeyChar) { | |
# [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($cursor + 1) | |
# } | |
# else { | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Insert("$($key.KeyChar)") | |
# } | |
# } | |
# Set-PSReadLineKeyHandler -Key Backspace ` | |
# -BriefDescription SmartBackspace ` | |
# -LongDescription "Delete previous character or matching quotes/parens/braces" ` | |
# -ScriptBlock { | |
# param($key, $arg) | |
# $line = $null | |
# $cursor = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor) | |
# if ($cursor -gt 0) { | |
# $toMatch = $null | |
# if ($cursor -lt $line.Length) { | |
# switch ($line[$cursor]) { | |
# <#case#> '"' { $toMatch = '"'; break } | |
# <#case#> "'" { $toMatch = "'"; break } | |
# <#case#> ')' { $toMatch = '('; break } | |
# <#case#> ']' { $toMatch = '['; break } | |
# <#case#> '}' { $toMatch = '{'; break } | |
# } | |
# } | |
# if ($toMatch -ne $null -and $line[$cursor - 1] -eq $toMatch) { | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Delete($cursor - 1, 2) | |
# } | |
# else { | |
# [Microsoft.PowerShell.PSConsoleReadLine]::BackwardDeleteChar($key, $arg) | |
# } | |
# } | |
# } | |
# #endregion Smart Insert/Delete | |
# # Sometimes you enter a command but realize you forgot to do something else first. | |
# # This binding will let you save that command in the history so you can recall it, | |
# # but it doesn't actually execute. It also clears the line with RevertLine so the | |
# # undo stack is reset - though redo will still reconstruct the command line. | |
# Set-PSReadLineKeyHandler -Key Alt+w ` | |
# -BriefDescription SaveInHistory ` | |
# -LongDescription "Save current line in history but do not execute" ` | |
# -ScriptBlock { | |
# param($key, $arg) | |
# $line = $null | |
# $cursor = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor) | |
# [Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory($line) | |
# [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() | |
# } | |
# # Insert text from the clipboard as a here string | |
# Set-PSReadLineKeyHandler -Key Ctrl+V ` | |
# -BriefDescription PasteAsHereString ` | |
# -LongDescription "Paste the clipboard text as a here string" ` | |
# -ScriptBlock { | |
# param($key, $arg) | |
# Add-Type -Assembly PresentationCore | |
# if ([System.Windows.Clipboard]::ContainsText()) { | |
# # Get clipboard text - remove trailing spaces, convert \r\n to \n, and remove the final \n. | |
# $text = ([System.Windows.Clipboard]::GetText() -replace "\p{Zs}*`r?`n", "`n").TrimEnd() | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Insert("@'`n$text`n'@") | |
# } | |
# else { | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Ding() | |
# } | |
# } | |
# # Sometimes you want to get a property of invoke a member on what you've entered so far | |
# # but you need parens to do that. This binding will help by putting parens around the current selection, | |
# # or if nothing is selected, the whole line. | |
# Set-PSReadLineKeyHandler -Key 'Alt+(' ` | |
# -BriefDescription ParenthesizeSelection ` | |
# -LongDescription "Put parenthesis around the selection or entire line and move the cursor to after the closing parenthesis" ` | |
# -ScriptBlock { | |
# param($key, $arg) | |
# $selectionStart = $null | |
# $selectionLength = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetSelectionState([ref]$selectionStart, [ref]$selectionLength) | |
# $line = $null | |
# $cursor = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor) | |
# if ($selectionStart -ne -1) { | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Replace($selectionStart, $selectionLength, '(' + $line.SubString($selectionStart, $selectionLength) + ')') | |
# [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($selectionStart + $selectionLength + 2) | |
# } | |
# else { | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Replace(0, $line.Length, '(' + $line + ')') | |
# [Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine() | |
# } | |
# } | |
# # Each time you press Alt+', this key handler will change the token | |
# # under or before the cursor. It will cycle through single quotes, double quotes, or | |
# # no quotes each time it is invoked. | |
# Set-PSReadLineKeyHandler -Key "Alt+'" ` | |
# -BriefDescription ToggleQuoteArgument ` | |
# -LongDescription "Toggle quotes on the argument under the cursor" ` | |
# -ScriptBlock { | |
# param($key, $arg) | |
# $ast = $null | |
# $tokens = $null | |
# $errors = $null | |
# $cursor = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$ast, [ref]$tokens, [ref]$errors, [ref]$cursor) | |
# $tokenToChange = $null | |
# foreach ($token in $tokens) { | |
# $extent = $token.Extent | |
# if ($extent.StartOffset -le $cursor -and $extent.EndOffset -ge $cursor) { | |
# $tokenToChange = $token | |
# # If the cursor is at the end (it's really 1 past the end) of the previous token, | |
# # we only want to change the previous token if there is no token under the cursor | |
# if ($extent.EndOffset -eq $cursor -and $foreach.MoveNext()) { | |
# $nextToken = $foreach.Current | |
# if ($nextToken.Extent.StartOffset -eq $cursor) { | |
# $tokenToChange = $nextToken | |
# } | |
# } | |
# break | |
# } | |
# } | |
# if ($tokenToChange -ne $null) { | |
# $extent = $tokenToChange.Extent | |
# $tokenText = $extent.Text | |
# if ($tokenText[0] -eq '"' -and $tokenText[-1] -eq '"') { | |
# # Switch to no quotes | |
# $replacement = $tokenText.Substring(1, $tokenText.Length - 2) | |
# } | |
# elseif ($tokenText[0] -eq "'" -and $tokenText[-1] -eq "'") { | |
# # Switch to double quotes | |
# $replacement = '"' + $tokenText.Substring(1, $tokenText.Length - 2) + '"' | |
# } | |
# else { | |
# # Add single quotes | |
# $replacement = "'" + $tokenText + "'" | |
# } | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Replace( | |
# $extent.StartOffset, | |
# $tokenText.Length, | |
# $replacement) | |
# } | |
# } | |
# # This example will replace any aliases on the command line with the resolved commands. | |
# Set-PSReadLineKeyHandler -Key "Alt+%" ` | |
# -BriefDescription ExpandAliases ` | |
# -LongDescription "Replace all aliases with the full command" ` | |
# -ScriptBlock { | |
# param($key, $arg) | |
# $ast = $null | |
# $tokens = $null | |
# $errors = $null | |
# $cursor = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$ast, [ref]$tokens, [ref]$errors, [ref]$cursor) | |
# $startAdjustment = 0 | |
# foreach ($token in $tokens) { | |
# if ($token.TokenFlags -band [TokenFlags]::CommandName) { | |
# $alias = $ExecutionContext.InvokeCommand.GetCommand($token.Extent.Text, 'Alias') | |
# if ($alias -ne $null) { | |
# $resolvedCommand = $alias.ResolvedCommandName | |
# if ($resolvedCommand -ne $null) { | |
# $extent = $token.Extent | |
# $length = $extent.EndOffset - $extent.StartOffset | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Replace( | |
# $extent.StartOffset + $startAdjustment, | |
# $length, | |
# $resolvedCommand) | |
# # Our copy of the tokens won't have been updated, so we need to | |
# # adjust by the difference in length | |
# $startAdjustment += ($resolvedCommand.Length - $length) | |
# } | |
# } | |
# } | |
# } | |
# } | |
# # F1 for help on the command line - naturally | |
# Set-PSReadLineKeyHandler -Key F1 ` | |
# -BriefDescription CommandHelp ` | |
# -LongDescription "Open the help window for the current command" ` | |
# -ScriptBlock { | |
# param($key, $arg) | |
# $ast = $null | |
# $tokens = $null | |
# $errors = $null | |
# $cursor = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$ast, [ref]$tokens, [ref]$errors, [ref]$cursor) | |
# $commandAst = $ast.FindAll( { | |
# $node = $args[0] | |
# $node -is [CommandAst] -and | |
# $node.Extent.StartOffset -le $cursor -and | |
# $node.Extent.EndOffset -ge $cursor | |
# }, $true) | Select-Object -Last 1 | |
# if ($commandAst -ne $null) { | |
# $commandName = $commandAst.GetCommandName() | |
# if ($commandName -ne $null) { | |
# $command = $ExecutionContext.InvokeCommand.GetCommand($commandName, 'All') | |
# if ($command -is [AliasInfo]) { | |
# $commandName = $command.ResolvedCommandName | |
# } | |
# if ($commandName -ne $null) { | |
# Get-Help $commandName -ShowWindow | |
# } | |
# } | |
# } | |
# }# Cycle through arguments on current line and select the text. This makes it easier to quickly change the argument if re-running a previously run command from the history | |
# # or if using a psreadline predictor. You can also use a digit argument to specify which argument you want to select, i.e. Alt+1, Alt+a selects the first argument | |
# # on the command line. | |
# Set-PSReadLineKeyHandler -Key Alt+a ` | |
# -BriefDescription SelectCommandArguments ` | |
# -LongDescription "Set current selection to next command argument in the command line. Use of digit argument selects argument by position" ` | |
# -ScriptBlock { | |
# param($key, $arg) | |
# $ast = $null | |
# $cursor = $null | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$ast, [ref]$null, [ref]$null, [ref]$cursor) | |
# $asts = $ast.FindAll( { | |
# $args[0] -is [System.Management.Automation.Language.ExpressionAst] -and | |
# $args[0].Parent -is [System.Management.Automation.Language.CommandAst] -and | |
# $args[0].Extent.StartOffset -ne $args[0].Parent.Extent.StartOffset | |
# }, $true) | |
# if ($asts.Count -eq 0) { | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Ding() | |
# return | |
# } | |
# $nextAst = $null | |
# if ($null -ne $arg) { | |
# $nextAst = $asts[$arg - 1] | |
# } | |
# else { | |
# foreach ($ast in $asts) { | |
# if ($ast.Extent.StartOffset -ge $cursor) { | |
# $nextAst = $ast | |
# break | |
# } | |
# } | |
# if ($null -eq $nextAst) { | |
# $nextAst = $asts[0] | |
# } | |
# } | |
# $startOffsetAdjustment = 0 | |
# $endOffsetAdjustment = 0 | |
# if ($nextAst -is [System.Management.Automation.Language.StringConstantExpressionAst] -and | |
# $nextAst.StringConstantType -ne [System.Management.Automation.Language.StringConstantType]::BareWord) { | |
# $startOffsetAdjustment = 1 | |
# $endOffsetAdjustment = 2 | |
# } | |
# [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($nextAst.Extent.StartOffset + $startOffsetAdjustment) | |
# [Microsoft.PowerShell.PSConsoleReadLine]::SetMark($null, $null) | |
# [Microsoft.PowerShell.PSConsoleReadLine]::SelectForwardChar($null, ($nextAst.Extent.EndOffset - $nextAst.Extent.StartOffset) - $endOffsetAdjustment) | |
# } | |
# # Allow you to type a Unicode code point, then pressing `Alt+x` to transform it into a Unicode char. | |
# Set-PSReadLineKeyHandler -Chord 'Alt+x' ` | |
# -BriefDescription ToUnicodeChar ` | |
# -LongDescription "Transform Unicode code point into a UTF-16 encoded string" ` | |
# -ScriptBlock { | |
# $buffer = $null | |
# $cursor = 0 | |
# [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref] $buffer, [ref] $cursor) | |
# if ($cursor -lt 4) { | |
# return | |
# } | |
# $number = 0 | |
# $isNumber = [int]::TryParse( | |
# $buffer.Substring($cursor - 4, 4), | |
# [System.Globalization.NumberStyles]::AllowHexSpecifier, | |
# $null, | |
# [ref] $number) | |
# if (-not $isNumber) { | |
# return | |
# } | |
# try { | |
# $unicode = [char]::ConvertFromUtf32($number) | |
# } | |
# catch { | |
# return | |
# } | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Delete($cursor - 4, 4) | |
# [Microsoft.PowerShell.PSConsoleReadLine]::Insert($unicode) | |
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module CompletionPredictor | |
# Import-Module 'C:\Users\power\Documents\GitHub\vcpkg\scripts\posh-vcpkg' | |
Import-Module 'C:\Users\power\Documents\PowerShell\_rg.ps1' | |
# Import-Module PSReadLine | |
# Import-Module PSFzf | |
# Import-Module 'C:\Users\power\Documents\PowerShell\Modules\Catpuccin\Catppuccin.psm1' | |
# Import-Module 'C:\Users\power\vcpkg\scripts\posh-vcpkg' | |
# Get-Module -ListAvailable -All | Group-Object -Property Name | Sort-Object -Property Count | Where-Object Count -GT 1 | ForEach-Object { Write-Host -ForegroundColor blue $_.Name; $sorted = $_.Group | Sort-Object version $latest = $($sorted | Select-Object -Last 1).Version; $previous = $($sorted | Where-Object Version -LT $latest | Select-Object -Last 1).Version; $legacy = $($sorted | Where-Object Version -LT $latest | Select-Object -First 1).Version; $_.Group | Where-Object Version -LT $latest | Remove-Module | Tee-Object -Variable Removed ; Uninstall-PSResource -Name $_.Name -Version "[$($legacy.Version), $($previous.Version)]" } | |
$host.ui.RawUI.WindowTitle = "PowerShell $($PSVersionTable.PSVersion)" | |
# Import-Module 'C:\Users\power\vcpkg\scripts\posh-vc⍺⍺⊂pkg' | |
#34de4b3d-13a8-4540-b76d-b9e8d3851756 PowerToys CommandNotFound module | |
Import-Module "C:\Program Files\PowerToys\WinGetCommandNotFound.psd1" | |
#34de4b3d-13a8-4540-b76d-b9e8d3851756 | |
Invoke-Command { | |
$private:keyboardSuggestions = 'Ctrl+t' | |
$private:keyboardHistory = 'Ctrl+r' | |
$private:commandOverride = [ScriptBlock] { param($Location) Write-Host $Location } | |
$private:commandHandler = [ScriptBlock] { Invoke-FzfTabCompletion - } | |
Set-PsFzfOption -PSReadlineChordProvider $keyboardSuggestions -PSReadlineChordReverseHistory $keyboardHistory | |
Set-PsFzfOption -AltCCommand $commandOverride | |
Set-PsFzfOption -TabExpansion | |
Set-PSReadLineOption -ShowToolTips | |
Set-PSReadLineOption -PredictionSource HistoryAndPlugin | |
Set-PSReadLineOption -PredictionViewStyle ListView | |
Set-PSReadLineKeyHandler -Key Tab -ScriptBlock $commandHandler | |
Set-PSReadLineKeyHandler -Chord 'Ctrl+Spacebar' -Function MenuComplete | |
"Started at '$(Get-Location)' with $(Get-Module | Measure-Object | Select-Object -ExpandProperty Count) loaded modules." | Out-Default | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config_live_reload = true | |
import = [ | |
"C:/Users/power/AppData/Roaming/alacritty/themes/catppuccin_mocha.toml", | |
] | |
shell.program = "pwsh" | |
working_directory = "C:/Users/power" | |
live_config_reload = true | |
[window] | |
dynamic_title = true | |
padding = { x = 8, y = 8 } | |
[font] | |
normal.family = "Cascadia Mono" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.cargo/.crates.toml