Tab completion to suggest executables first #16062

Closed
opened 2026-01-31 04:56:25 +00:00 by claunia · 1 comment
Owner

Originally created by @Reyhn3 on GitHub (Dec 7, 2021).

Description of the new feature/enhancement

When pressing the tab-key to have the terminal autofill a suggestion of a file name present in the current folder, the first suggestion should be an .exe-file if there is a file matching the pattern, and only after that any other alternatives (in the way it does now).

The reason is that when I use tab completion, I always use it for folder navigation (not applicable) and to not have to type the full name of the executable I want to run.

Further Feature Examination

Note that this feature does not necessarily have to be limited to executables. It could just as well (with the same implementation, I believe) be used for other types of well-known file system entities.

For example, if I just recently launched a .cmd-file (which is not, the first suggestion), the next time I use tab completion the first suggestion could be the same .cmd-file again. The first time I used tab completion, the most likely candidate was the .exe-file but I chose a less likely candidate. On the second time the previous .cmd-file is more likely. I am trying to show that there is room for more intelligence here, as the keyword is "most likely". However, this could also lead to confusion and annoyance, so extending the feature this far should be evaluated carefully first (:

Proposed technical implementation details (optional)

  1. Precondition: The application already has a list of well-known executable types (.exe, .bat, .cmd, .sh etc.) prioritized in the most appropriate way (i.e. exe before cmd, cmd before bat and so on).
  2. Assemble the list of potential suggestions (i.e. how I guess tab completion works now).
  3. Sort the suggestions based on the list in step 0.
  4. Use the topmost suggestion.
  5. If pressing tab again, continue cycling through the ordered list until there are no more well-known types.
  6. If the ordered list is exhausted, continue with the "classic" suggestions.

When using tab completion to cycle through suggestions, I expect the most likely suggestion to be the first suggestion, followed by relevant suggestions, and lastly anything else that does not seem the user's most likely choice.

Originally created by @Reyhn3 on GitHub (Dec 7, 2021). # Description of the new feature/enhancement When pressing the tab-key to have the terminal autofill a suggestion of a file name present in the current folder, **the first suggestion should be an .exe-file** if there is a file matching the pattern, and only after that any other alternatives (in the way it does now). The reason is that when I use tab completion, I always use it for folder navigation (not applicable) and to not have to type the full name of the executable I want to run. ## Further Feature Examination Note that this feature does not necessarily have to be limited to executables. It could just as well (with the same implementation, I believe) be used for other types of well-known file system entities. For example, if I just recently launched a .cmd-file (which is **not,** the first suggestion), the next time I use tab completion the first suggestion could be the same .cmd-file again. The first time I used tab completion, the most likely candidate was the .exe-file but I chose a less likely candidate. On the second time the previous .cmd-file is more likely. I am trying to show that there is room for more intelligence here, as the keyword is "most likely". However, this could also lead to confusion and annoyance, so extending the feature this far should be evaluated carefully first (: <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> # Proposed technical implementation details (optional) 0. Precondition: The application already has a list of well-known executable types (.exe, .bat, .cmd, .sh etc.) prioritized in the most appropriate way (i.e. exe before cmd, cmd before bat and so on). 1. Assemble the list of potential suggestions (i.e. how I guess tab completion works now). 2. Sort the suggestions based on the list in step 0. 3. Use the topmost suggestion. 4. If pressing tab again, continue cycling through the ordered list until there are no more well-known types. 5. If the ordered list is exhausted, continue with the "classic" suggestions. <!-- A clear and concise description of what you want to happen. --> When using tab completion to cycle through suggestions, I expect the most likely suggestion to be the first suggestion, followed by relevant suggestions, and lastly anything else that does not seem the user's most likely choice.
Author
Owner

@zadjii-msft commented on GitHub (Dec 7, 2021):

If you're using PowerShell, then this sounds like a suggestion to file on that shell directly, over at https://github.com/PowerShell/PowerShell (or possibly https://github.com/PowerShell/PSReadline, I'm not sure if PSReadline gets involved in tab completion).

If you're using cmd.exe, unfortunately, we won't be updating cmd.exe anytime soon. Neat idea, but not something we can change unfortunately.

@zadjii-msft commented on GitHub (Dec 7, 2021): If you're using PowerShell, then this sounds like a suggestion to file on that shell directly, over at https://github.com/PowerShell/PowerShell (or possibly https://github.com/PowerShell/PSReadline, I'm not sure if PSReadline gets involved in tab completion). If you're using `cmd.exe`, unfortunately, [we won't be updating `cmd.exe` anytime soon](https://github.com/microsoft/terminal/blob/main/doc/Niksa.md#cmd). Neat idea, but not something we can change unfortunately.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16062