add enhancements to CLI command-line completion and history

- Added support for pyreadline3 so that Window users can benefit.
- Added the !search command to search the history for a matching string:
~~~
!search puppies
[20] puppies at the food bowl -Ak_lms
[54] house overrun by hungry puppies -C20 -s100
~~~
- Added the !clear command to clear the in-memory and on-disk
  command history.
This commit is contained in:
Lincoln Stein
2022-10-04 14:57:48 -04:00
parent 18e667f98e
commit d16f0c8a8f
5 changed files with 61 additions and 13 deletions

View File

@ -183,6 +183,15 @@ def main_loop(gen, opt, infile):
completer.show_history()
continue
elif subcommand.startswith('search'):
search_str = command.replace('!search ','',1)
completer.show_history(search_str)
continue
elif subcommand.startswith('clear'):
completer.clear_history()
continue
elif re.match('^(\d+)',subcommand):
command_no = re.match('^(\d+)',subcommand).groups()[0]
command = completer.get_line(int(command_no))