help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Is it possible to get directory style tab completion, while


From: Mara Kim
Subject: [Help-bash] Is it possible to get directory style tab completion, while preventing Bash from adding its own slashes?
Date: Tue, 9 Apr 2013 07:55:41 -0500

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.  
https://github.com/resultsreturned/to/

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:
https://github.com/resultsreturned/to/issues/25

Thanks,
Mara

reply via email to

[Prev in Thread] Current Thread [Next in Thread]