You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a small Typer script with autocompletions (see MWE).
Open a bash shell.
Trigger autocompletion hitting TAB.
I see the results have been sorted non-naturally:
$ typer example.py run <TAB>
1 one
10 ten
2 two
3 three
I would like to be able to see the results in an order of my choosing. Perhaps let me arrange the items in the completion function, and not let bash sort them in its own way afterwards.
It took me a while to find the cause, but it's due to using complete -o default:
Even if there's a reason for this change, there is currently no option to, for instance, use natural sorting, aside from editing the generated .sh file in $HOME/.bash_completions, which does solve the issue for me.
Operating System
Linux
Operating System Details
I think this is not applicable, but anyway:
OS: Ubuntu 22.04.5 LTS
Linux giru 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Bash version: GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
First Check
Commit to Help
Example Code
Description
Create a small Typer script with autocompletions (see MWE).
Open a bash shell.
Trigger autocompletion hitting TAB.
I see the results have been sorted non-naturally:
I would like to be able to see the results in an order of my choosing. Perhaps let me arrange the items in the completion function, and not let bash sort them in its own way afterwards.
It took me a while to find the cause, but it's due to using
complete -o default
:typer/typer/_completion_shared.py
Line 33 in 0b89650
This overrides the Click equivalent, which uses
complete -o nosort
:https://github.com/pallets/click/blob/934813e4d421071a1b3db3973c02fe2721359a6e/src/click/shell_completion.py#L119
This difference was mentioned in #682:
Even if there's a reason for this change, there is currently no option to, for instance, use natural sorting, aside from editing the generated
.sh
file in$HOME/.bash_completions
, which does solve the issue for me.Operating System
Linux
Operating System Details
I think this is not applicable, but anyway:
Ubuntu 22.04.5 LTS
Linux giru 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Typer Version
0.15.1
Python Version
Python 3.13.0
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions