TIP: Make bash tab completion ignore .svn directories
Having to tab through the fifty million otherwise empty “net/mycompany/project/unit/subunit” directories that the Java ecosystem necessitates has consistently driven me crazy because completion stops at each step to let me choose the .svn directory, and I have to look and type the first letter of the directory I actually want to make it continue.
It’s actually really easy to fix this:
export FIGNORE=.svn
$FIGNORE is just a colon-separated list of suffixes to ignore when doing tab completion.
Ah! Good ol’ FIGNORE. Thanks, +1, etc.
thanks! this makes my life much easier
Actually it should be export FIGNORE=svn (the dot is already implied)
If you leave the dot off it will ignore anything that ends with svn.
% ls ./<tab>
hisvn/ svn/ .svn/ svn-test/ test/ test-svn/
% export FIGNORE=svn
% ls ./<tab>
svn-test/ test/
I noticed a Stack Overflow post where some other people were seeing a similar discrepancy, so I glanced at the source and I think I see the source of the confusion:
static int
name_is_acceptable (name)
const char *name;
{
struct ign *p;
int nlen;
for (nlen = strlen (name), p = fignore.ignores; p->val; p++)
{
if (nlen > p->len && p->len > 0 && STREQ (p->val, &name[nlen - p->len]))
return (0);
}
return (1);
}
Note that the length of the path being checked must be greater than the length of the item in FIGNORE
. So FIGNORE=.svn
will not reject an entry that is just .svn
The catch is that leading path components are considered as part of the name. Example:
% ls <tab>
Breakpoint 1, name_is_acceptable (name=0x71d510 ".svn") at bashline.c:2536
% ls .<tab>
Breakpoint 1, name_is_acceptable (name=0x73dcb0 "./.svn") at bashline.c:2536
So, FIGNORE=.svn
will only ignore the directory .svn
when there are leading path components.
Awesome. Thanks.
thx mate^^ annettte (who apparently met u in nippon) gave me this address and look here, reading a few entries and already updated my bashrc :) hope it works