Skip to content

Commit a9b7121

Browse files
authored
Merge pull request #400 from python-cmd2/complete_alias
Completing alias names in value field of alias command since aliases …
2 parents b48d6b5 + c76a8ac commit a9b7121

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cmd2/cmd2.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,13 +2142,15 @@ def do_alias(self, arglist):
21422142
errmsg = "Aliases can not contain: {}".format(invalidchars)
21432143
self.perror(errmsg, traceback_war=False)
21442144

2145-
21462145
def complete_alias(self, text, line, begidx, endidx):
21472146
""" Tab completion for alias """
2147+
alias_names = set(self.aliases.keys())
2148+
visible_commands = set(self.get_visible_commands())
2149+
21482150
index_dict = \
21492151
{
2150-
1: self.aliases,
2151-
2: self.get_visible_commands()
2152+
1: alias_names,
2153+
2: list(alias_names | visible_commands)
21522154
}
21532155
return self.index_based_complete(text, line, begidx, endidx, index_dict, self.path_complete)
21542156

0 commit comments

Comments
 (0)