I was just working on a bash completion for my repo management tool (link) and came across a completion problem I couldn't find an answer to. In my tool, all repositories are stored under a root source directory ~/src, and are three directories deep under that. The top directory is the website, the second is the user, and the third is the repo itself. For example github.com/zig/ziglang. My tool repo has a command repo cd , which will try to find a project matching the path you specify.