bd icon indicating copy to clipboard operation
bd copied to clipboard

Sort bash completions in dir nesting order

Open stacktracer opened this issue 8 years ago • 3 comments

Currently completions are ordered alphabetically. Would be nice if there were an option to sort them in the order in which they appear in the path -- so if current working dir is /home/user/Desktop/stuff/, then autocomplete would go:

$ bd <tab-key><tab-key>
home user Desktop

stacktracer avatar Apr 16 '17 15:04 stacktracer

Not sure how this would handle duplicate entries (e.g. if working dir is /home/USER/Desktop/USER/stuff).

stacktracer avatar Apr 16 '17 15:04 stacktracer

This turns out to be pretty trivial. In the bash-completion file, just add -o nosort:

_bd()
{
    ...
}
complete -o nosort -F _bd bd

stacktracer avatar Apr 16 '17 15:04 stacktracer

Duplicate entries are simply shown more than once in the list -- which is fine with me.

stacktracer avatar Apr 16 '17 15:04 stacktracer