Created
          October 27, 2025 14:04 
        
      - 
      
- 
        Save FriedrichWeinmann/11322cf9959ea28ba6792a94581ea1c1 to your computer and use it in GitHub Desktop. 
    Make items in a list easily, manually accessible with shortcuts, such as "L0", "L1", "L2", ...
  
        
  
    
      This file contains hidden or 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 Register-ListReader { | |
| [CmdletBinding()] | |
| param ( | |
| $List, | |
| $Property | |
| ) | |
| Register-ListHandler | |
| $global:__LR_Config = @{ | |
| List = $List | |
| Property = $Property | |
| } | |
| } | |
| function Get-ListValue { | |
| [CmdletBinding()] | |
| param ( | |
| [int] | |
| $Value = $global:__LR_Config.Index | |
| ) | |
| if (-not $global:__LR_Config.List) { return } | |
| $item = $global:__LR_Config.List[$Value] | |
| if ($global:__LR_Config.Property) { $item.$($global:__LR_Config.Property) } | |
| else { $item } | |
| } | |
| function Register-ListHandler { | |
| [CmdletBinding()] | |
| param () | |
| $ExecutionContext.InvokeCommand.CommandNotFoundAction = { | |
| Param ($Name, $EventArgs) | |
| if ($Name.Trim('.\') -notmatch '^L(?<id>\d+)$') { return } | |
| $global:__LR_Config.Index = $matches.id | |
| $EventArgs.Command = Get-Command Get-ListValue | |
| $EventArgs.StopSearch = $true | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment