Support for partial commands
See original GitHub issueSome shells accept and interpret partial commands and it would be a great feature to be included.
Let’s take a look an example:
By default cmd2 includes quit command, which is used to end the cmd-session.
In many scenarios, it would be useful to allow the user just write q to get the same functionality.
Of course cmd2 support many ways of doing this, such as alias, macros or shortcuts, however, all of them should be created “manually” for each command.
Of course, there may be conflicts such not always the first letter could be used.
Let’s say we have 2 different commands called stop and show (that can be found in many shells that support this kind of things).
In this scenario, it would be great to automatically cmd2 allow using sh or sho as an alias of the command show, in the same way as st or sto as alias of stop. Of course s have 2 possible candidates, so it may be considered just an invalid/incomplete command.
A possible implementation: One possible implementation that may even work with subcommands is simple: 1 - the user input a command 2.1 - If the command exists or is an alias execute it as always 2.2 - if the commands does not exists, call autocomplete 3.1 - if the autocomplete returns none or more than 1 results, return invalid command as always 3.2 - if the autocomplete returns exactly one result, try to run that one and store it as if the user has written it down.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)

Top Related StackOverflow Question
I’ve never actually used it but I know we have this plugin for abbreviated command support. It seems very similar to what you’re describing.
https://github.com/python-cmd2/cmd2-abbrev
Thank you @kmvanbrunt . I’ll probably reopen this issue when I have time to work on it. I still did not forget about it.