@@ -41,13 +41,14 @@ $VaultSearchParameters = @{
4141 # WARN: First time I used ScriptBlock
4242 $process_string = {
4343 param ($line )
44- $matchesSearchFunction = " rgj|rgo"
44+ $matchesSearchFunction = " rgj|rgo|ig "
4545 if ($line -match " ^($matchesSearchFunction )" ) {
4646 # TODO: further enhanced by adding different flag at this point.
4747 switch - Regex ($line ) {
4848 " ^(?!.*-w$)" { $SearchWithQuery = " $line -w" ; break }
4949 " ^rgj" { $SearchWithQuery = $line -replace " ^rgj" , " rgo" ; break }
5050 " ^rgo" { $SearchWithQuery = $line -replace " -w$" , " " ; break }
51+ " ^igj" { $SearchWithQuery = $line -replace " ^igj" , " ig" ; break }
5152 }
5253 }
5354 else {
@@ -79,16 +80,22 @@ $quickZoxide = {
7980 $process_string = {
8081 param ($line )
8182 $existedCd = " cd|z|zq"
82- if ($line -match " ^(${existedCd} )i" ) {
83- $SearchWithQuery = $line
84- }
85- elseif ($line -match " ^($existedCd )" ) {
86- $matchString = $Matches [0 ]
87- $SearchWithQuery = $line -replace " ${matchString} " , " ${matchString} i"
83+ switch - Regex ($line ) {
84+ " ^(${existedCd} )i\s" {
85+ $matchString = $Matches [0 ]
86+ $SearchWithQuery = $line -replace " ${matchString} " , " zz "
87+ break ;
88+ }
89+ " ^(${existedCd} )(\s|$)" {
90+ $matchString = $Matches [1 ]
91+ $SearchWithQuery = $line -replace " ^${matchString} (\s|$)" , " ${matchString} i "
92+ break
93+ }
94+ default {
95+ $SearchWithQuery = " $searchFunction $line "
96+ break ;
97+ }
8898 }
89- else {
90- $SearchWithQuery = " $searchFunction $line "
91- }
9299 return $SearchWithQuery
93100 }
94101 if ($line -match " [a-z]" ) {
@@ -408,7 +415,7 @@ $openEditorParameters = @{
408415$rgToNvimParameters = @ {
409416 Key = ' Alt+v'
410417 BriefDescription = ' open `ig`'
411- LongDescription = ' Invoke vr in place of rg.'
418+ LongDescription = ' Invoke ig in place of rg.'
412419 ScriptBlock = {
413420 param ($key , $arg ) # The arguments are ignored in this example
414421
@@ -420,7 +427,7 @@ $rgToNvimParameters = @{
420427 if ($line -match ' ^rg' ) {
421428 # INFO: Replace could actually increase the length of original strings.
422429 # So I could be longer than the start.
423- [Microsoft.PowerShell.PSConsoleReadLine ]::Replace(0 , 2 , " vr " )
430+ [Microsoft.PowerShell.PSConsoleReadLine ]::Replace(0 , 2 , " ig " )
424431 }
425432 else {
426433 # INFO: check history for the latest match commands
@@ -430,7 +437,7 @@ $rgToNvimParameters = @{
430437 | Select-Object - Index 0 `
431438
432439 [Microsoft.PowerShell.PSConsoleReadLine ]::Insert($SearchWithQuery )
433- [Microsoft.PowerShell.PSConsoleReadLine ]::Replace(0 , 2 , " vr " )
440+ [Microsoft.PowerShell.PSConsoleReadLine ]::Replace(0 , 2 , " ig " )
434441 }
435442 [Microsoft.PowerShell.PSConsoleReadLine ]::AcceptLine()
436443
@@ -450,30 +457,29 @@ $rgToRggParameters = @{
450457 $cursor = $null
451458 [Microsoft.PowerShell.PSConsoleReadLine ]::GetBufferState([ref ]$line ,
452459 [ref ]$cursor )
453- if ($line -match ' ^rg ' ) {
454- # INFO: Replace could actually increase the length of original strings.
455- # So I could be longer than the start.
456- [Microsoft.PowerShell.PSConsoleReadLine ]::Replace(0 , 2 , " rgr" )
460+ $matchFunction = " rg|rgj"
461+ $injectSearch = {
462+ param ($command )
463+ $command -match " ^($matchFunction )\s"
464+ [Microsoft.PowerShell.PSConsoleReadLine ]::Replace(0 , $Matches [0 ].Length, " rgr " )
465+ }
466+ if ($line -match " ^($matchFunction )" ) {
467+ $injectSearch.Invoke ($line )
457468 }
458469 else {
459- # INFO: check history for the latest match commands
460470 $SearchWithQuery = Get-History - Count 40 `
461471 | Sort-Object - Property Id - Descending `
462- | Where-Object { $_.CommandLine -match " ^rg " }
472+ | Where-Object { $_.CommandLine -match " ^( $matchFunction ) " }
463473 | Select-Object - Index 0 `
464474
465475 [Microsoft.PowerShell.PSConsoleReadLine ]::Insert($SearchWithQuery )
466- [ Microsoft.PowerShell.PSConsoleReadLine ]::Replace( 0 , 2 , " rgr " )
476+ $injectSearch .Invoke ( $SearchWithQuery )
467477 }
468478 [Microsoft.PowerShell.PSConsoleReadLine ]::AcceptLine()
469479
470480 }
471481}
472482
473-
474-
475-
476-
477483$quickEscParameters = @ {
478484 Key = ' Ctrl+k'
479485 BriefDescription = ' Open Kicad'
@@ -493,9 +499,6 @@ $quickEscParameters = @{
493499 }
494500}
495501
496- function Invoke-SudoPwsh {
497- sudo -- inline pwsh - Command " $args "
498- }
499502$sudoRunParameters = @ {
500503 Key = ' Ctrl+shift+x'
501504 BriefDescription = ' Execute as sudo (in pwsh).'
0 commit comments