Hi help-bash!
I am having a problem with a very strange situation with tab completions
I have made a script called "to", which allows you to bookmark directories in bash. Â
Essentially, it allows you to do the following operations:
$ to -b foo   # bookmark current directory as "foo"
then sometime later
$ to foo   # cd to the foo bookmark
In addition, you could navigate to subdirectories of foo like so
$ to foo/bar
The script supports directory style tab completion (specifically, the behavior where just the "currect directory level" is shown in suggestions). Â However, since the arguments don't actually correlate to actual files, bash somtimes adds slashes where it shouldn't.
The suggestions themselves already have slashes out of necessity (ie. "foo/"), but if the current directory contains a folder named "foo", the displayed completion will be "foo//" instead of "foo/". Â Thankfully, this only seems to be affecting the way the completion is displayed, as the actual completion seems to be fine. Â I have a feeling this is a side effect of the "-o filenames" option to "complete"
If you wish to look at the source code, the tab completion code is in lines 105-202 of to.sh
A more detailed summary can be found here:
Thanks,
Mara