rapid7/metasploit-framework — pull request #637 by kernelsmith (2012-07-22 21:03:13+00:00)
Title: Adds console command aliasing

see commit history for details, but adds the 'alias' command to msfconsole.
Some other changes:
adds alias (cmd_alias) to core.rb
basically anything can be aliased using -f, except a few safe words like rm -rf and msfconsole, additionally an alias can't have the name alias otherwise a user could end up in a state where one cannot unalias an overaliased core command like 'set'.
Aliases will tab complete, and the alias command will tab complete with any loaded command or current alias (you can also alias an alias)
adds @aliases to core, accessed via an attr_reader and changed via the cmd_alias method
adds @allow_aliases, accessed via an attr_reader and set as a protected attr_writer by initialization and defangedness
allow_aliases follows the same relationship that command_passthru has

in order to allow cmd_alias to verify valid aliases, some changes were made to dispatcher_shell:
is_valid_dispatcher_command? was added which can search all or a specified dispatcher and has an option for whether to search deprecated commands. This provides the basis for
get_responding_dispatcher, which was also added. As a result, run_single was simplified by updating it to use get_responding_dispatcher. Possibly some other code could be updated with these methods, but I didn't want to go too nuts.