Search code examples
linuxbashcdarchlinux

How do I restrict cd arguments to directories in bash?


Currently, when I cd re[tab][tab], bash gives me options including files and directories. Since cd only allows directories as arguments, giving me non-directory options doesn't seem to offer any advantages. How can I modify it to only give directories as options? I'm using archlinux.

$ cd re
redrover.sh  research/

Solution

  • Bash already hase some pretty nice completion, but you can get this (and much more) if you install the advanced auto-completion:

    pacman -S bash-completion