Repository: xonsh/xonsh

Issue:
Configure xonsh to directly complete instead of displaying a menu if there's a single completion entry.
Is there a way to configure xonsh so that it directly completes the word instead of displaying a menu if there's a single completion entry? It's very difficult to browse directory tree without it.

## xonfig

    +------------------+----------------------+
    | xonsh            | 0.7.6.dev5           |
    | Git SHA          | 837c714a             |
    | Commit Date      | Aug 25 18:35:16 2018 |
    | Python           | 3.7.0                |
    | PLY              | 3.9                  |
    | have readline    | True                 |
    | prompt toolkit   | 1.0.15               |
    | shell type       | prompt_toolkit1      |
    | pygments         | 2.2.0                |
    | on posix         | True                 |
    | on linux         | True                 |
    | distro           | arch                 |
    | on darwin        | False                |
    | on windows       | False                |
    | on cygwin        | False                |
    | on msys2         | False                |
    | is superuser     | False                |
    | default encoding | utf-8                |
    | xonsh encoding   | utf-8                |
    | encoding errors  | surrogateescape      |
    +------------------+----------------------+
    


Discussion:
Hey @gsaga -- that should be the default behavior in that situation (and is the way it works on my machine).  Do you have any non-default options related to completions set in your `xonshrc`?
Try these command:
 
    mkdir /tmp/a/b/c/d/e
    cd /tmp/a

and then type `cd b` and press `tab` repeatedly. I would expect the shell to complete all the paths until e, the way it does in `zsh`, but instead it gets stuck on `c`.
I can confirm that. You can set `$COMPLETIONS_CONFIRM = '1'` as a workaround if you don't mind pressing `return` key to confirm the completion.
@gsaga - that sounds like a great feature! Would love to see the `cd` completer updated to allow this
@scopatz I've checked the `complete_path` function in `xonsh/completers/path.py` and looks like it just returns a set of completions, and it works correctly(returns a set of one entry if there's just one completion).

Implementing this feature might require modifying the tab completion mechanism (which calls various completer functions) so that it directly inserts the entry if there's only one.

The readline shell performs the completion as expected. Maybe some switch to prompt_toolkit needs to be tweaked.

Hmm interesting yeah, perhaps it does!
This is a weird one -- because it should allow the paths to continue to complete but @gsaga is correct that it starts offering the dropdown a couple folders deep, but there aren't any other valid completions at that point.  
Ha, figured this one out, PR incoming

Resolving patch:
diff --git a/xonsh/ptk2/key_bindings.py b/xonsh/ptk2/key_bindings.py
--- a/xonsh/ptk2/key_bindings.py
+++ b/xonsh/ptk2/key_bindings.py
@@ -344,34 +344,3 @@ def wrap_cursor_forward(event):
     @handle(Keys.ControlJ, filter=IsSearching())
     def accept_search(event):
         search.accept_search()
-
-    @handle(Keys.ControlI, filter=insert_mode)
-    def generate_completions(event):
-        """
-        Tab-completion: where the first tab completes the common suffix and the
-        second tab lists all the completions.
-
-        Notes
-        -----
-        This method was forked from the mainline prompt-toolkit repo.
-        Copyright (c) 2014, Jonathan Slenders, All rights reserved.
-        """
-        b = event.current_buffer
-
-        try:
-            start_completion = event.cli.start_completion
-        except AttributeError:  # PTK 2.0
-            start_completion = event.current_buffer.start_completion
-
-        def second_tab():
-            if b.complete_state:
-                b.complete_next()
-            else:
-                start_completion(select_first=False)
-
-        # On the second tab-press, or when already navigating through
-        # completions.
-        if event.is_repeat or b.complete_state:
-            second_tab()
-        else:
-            start_completion(insert_common_part=True, select_first=False)


Test patch: