diff options
author | Eric Lin <anselor@gmail.com> | 2018-05-03 17:00:01 -0400 |
---|---|---|
committer | Eric Lin <anselor@gmail.com> | 2018-05-03 17:00:01 -0400 |
commit | 94156f8a78b74588275141d27c0b633455fa4fc0 (patch) | |
tree | 989bdf91b64861ee20053b61ab411219519a4dff /cmd2/argcomplete_bridge.py | |
parent | c051c84fd44dda4b0c19f6ad01bb14ea970de260 (diff) | |
download | cmd2-git-94156f8a78b74588275141d27c0b633455fa4fc0.tar.gz |
Figured out how to detect the second tab press. Writing parameter hinting to stderr to bypass bash completion handling.
Diffstat (limited to 'cmd2/argcomplete_bridge.py')
-rw-r--r-- | cmd2/argcomplete_bridge.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/cmd2/argcomplete_bridge.py b/cmd2/argcomplete_bridge.py index 583f3345..3d53132e 100644 --- a/cmd2/argcomplete_bridge.py +++ b/cmd2/argcomplete_bridge.py @@ -228,15 +228,14 @@ else: output_stream.write(ifs.join(completions).encode(argcomplete.sys_encoding)) elif outstr: # if there are no completions, but we got something from stdout, try to print help - # trick the bash completion into thinking there are 2 completions that are unlikely # to ever match. - outstr = outstr.replace('\n', ' ').replace('\t', ' ').replace(' ', ' ').strip() - # generate a filler entry that should always sort first - filler = ' {0:><{width}}'.format('', width=len(outstr)/2) - outstr = ifs.join([filler, outstr]) - output_stream.write(outstr.encode(argcomplete.sys_encoding)) + comp_type = int(os.environ["COMP_TYPE"]) + if comp_type == 63: # type is 63 for second tab press + print(outstr.rstrip(), file=argcomplete.debug_stream, end='') + + output_stream.write(ifs.join([ifs, ' ']).encode(argcomplete.sys_encoding)) else: # if completions is None we assume we don't know how to handle it so let bash # go forward with normal filesystem completion |