summaryrefslogtreecommitdiffstats
path: root/Lib/cmd.py
diff options
context:
space:
mode:
authorConstantin Hong <hongconstantin@gmail.com>2023-12-05 07:24:56 (GMT)
committerGitHub <noreply@github.com>2023-12-05 07:24:56 (GMT)
commitaa5bee30abb28d73a838399f4c3a8bcdc5108fe3 (patch)
tree98d459e7dcd3e011709aa7f82d2e5919cce697f7 /Lib/cmd.py
parentdc824c5dc120ffed84bafd23f95e95a99678ed6a (diff)
downloadcpython-aa5bee30abb28d73a838399f4c3a8bcdc5108fe3.zip
cpython-aa5bee30abb28d73a838399f4c3a8bcdc5108fe3.tar.gz
cpython-aa5bee30abb28d73a838399f4c3a8bcdc5108fe3.tar.bz2
gh-102130: Support tab completion in cmd for Libedit. (GH-107748)
--- Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Diffstat (limited to 'Lib/cmd.py')
-rw-r--r--Lib/cmd.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/cmd.py b/Lib/cmd.py
index e933b8d..2e358d6 100644
--- a/Lib/cmd.py
+++ b/Lib/cmd.py
@@ -108,7 +108,15 @@ class Cmd:
import readline
self.old_completer = readline.get_completer()
readline.set_completer(self.complete)
- readline.parse_and_bind(self.completekey+": complete")
+ if readline.backend == "editline":
+ if self.completekey == 'tab':
+ # libedit uses "^I" instead of "tab"
+ command_string = "bind ^I rl_complete"
+ else:
+ command_string = f"bind {self.completekey} rl_complete"
+ else:
+ command_string = f"{self.completekey}: complete"
+ readline.parse_and_bind(command_string)
except ImportError:
pass
try: