bd
bd copied to clipboard
Sort bash completions in dir nesting order
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
Not sure how this would handle duplicate entries (e.g. if working dir is /home/USER/Desktop/USER/stuff).
This turns out to be pretty trivial. In the bash-completion file, just add -o nosort:
_bd()
{
...
}
complete -o nosort -F _bd bd
Duplicate entries are simply shown more than once in the list -- which is fine with me.