You can add the parent directory, ~/Desktop/_REPOS, to your CDPATH environment variable:
CDPATH="$CDPATH":"$HOME"/Desktop/_REPOS
Now, from any directory, you can type cd SpaceTab, and in addition to the subdirectories of your current directory, all the directories in ~/Desktop/_REPOS will show up. (Which is also the drawback of this method: more clutter.)
You can add a completion function to your .bashrc. The way you've started, you want the basenames of all the directories in ~/Desktop/_REPOS. To get autocompletion for directories, we can use the compgen -d builtin:
$ compgen -d "$HOME"/Desktop/_REPOS/
/home/me/Desktop/_REPOS/folder1
/home/me/Desktop/_REPOS/folder2
/home/me/Desktop/_REPOS/stackstuff
/home/me/Desktop/_REPOS/hellofolder
This returns the names of all subdirectories. It reduces to fewer candidates when the path is more specific:
$ compgen -d "$HOME"/Desktop/_REPOS/f
/home/me/Desktop/_REPOS/folder1
/home/me/Desktop/_REPOS/folder2
To remove everything but the basenames, we use shell parameter expansion, like this:
$ arr=(/path/to/dir1 /path/to/dir2)
$ echo "${arr[@]##*/}"
dir1 dir2
##*/ in the parameter expansion removes the longest possible match of */ from each element of arr, i.e., leaves only what's after the last forward slash – exactly what we want.
Now we put this together and into a function:
_comp_repo () {
# Get list of directories
# $2 is the word being completed
COMPREPLY=($(compgen -d "$HOME"/Desktop/_REPOS/"$2"))
# Reduce to basenames
COMPREPLY=("${COMPREPLY[@]##*/}")
}
This goes into your .bashrc, together with the instruction to use it for autocompletion with repo:
complete -F _comp_repo repo
Notice that your repo function should quote the $1 argument to make sure it handles directory names with special characters (spaces, tabs...) properly:
repo () {
cd ~/Desktop/_REPOS/"$1"
}