1

How to get bash to auto-complete cd commands only with directory names and ignore filenames (just as CMD on Windows)

Example:

I'm in

/some/folder/

I have

-rwxr-xr-x filesharp
-rwxr-xr-x fileshallow
-rwxr-xr-- file
drwxrwxrwx files

I want that when I enter cd f<tab>, bash auto-completes it as cd /home/dds/files not having to enter s manually: there's only a single directory matching my prefix.

EDIT: Solution found up to this point (add autocomplete -d cd to .bashrc)

Also would be great to have the "scroll trough names", available on Windows, when each time I press Tab I get the completion for a single file (or folder) matching the prefix I entered.

  • Yes it can be done. My system is set up this way, I am not sure how. I am using Debian, I have package bash-completion installed (I suspect that it is responsible). – ctrl-alt-delor Feb 18 at 13:57
  • related – Nahuel Fouilleul Feb 18 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.