I have studied this before, and it is not possible. The buffer accessed by the up arrow and function keys (for example, completion with F8 and the list that you see when you press F7 ) is executed in the session and cannot be changed.
However, what you can do to quickly access the commands in the history, including those that were added using Add-History , is the type # , followed by the template, and then press [TAB] to see all the commands in the history that correspond to pattern. For example, #dsquery[TAB] will expand to the very last command in history containing "dsquery", and pressing [TAB] will cycle through any other commands containing "dsquery" for more time.
How the pattern is matched is determined by the TabExpansion function. By default, a tab with a tab extension mainly works for strings of letters from a command, with no characters or spaces. You can check the function code by entering $function:TabExpansion . If you want, you can change the behavior of the tab extension by specifying its own TabExpansion function . If you are really not sure that you know what you are doing, I would recommend changing the existing code, and not starting from scratch, because you can violate other functions, because the TabExpansion function affects all tab completion at the prompt, for example, commands or execution paths tabs.
source share