I have my projects in a ~/Documents/EP_example_project naming scheme. They all live under ~/Documents.
I would like to create a bash-function that allows me to cd into a project-directory from whereever I am on the system; with autocomplete. Like so:
cdp E<tab>
# ... EAP_example_additional_project EP_example_project
P<tab>
# prompt now says:
cdp EP_example_project<enter>
# ... And I am in the project-directory.
That would be a bit easier then typing cd ~/Do<tab>EP<tab> everytime.
I do know the basics about creating a simple function, but cannot find how to add tab-autocompletion to that.
NOTE: while above reasoning makes little sense: the additional ~/Do is not that much overhead, it is the additional things I can do in such a function, like print the contents of a certain file if found (.birdseye), list the projects contents, last accessed dates and so on, that make this more interesting in future.
You could consider
CDPATH. You canexport CDPATH=~/Documentsto have all the directories under ~/Documents added for autocompletion. You can have a function or alias for this export command and set & unsetCDPATHas and when you need.Hope this helps!