Ignore a path entry with bash tab-completion

2019-04-27 03:24发布

I have two commands, foo and foo-bar, where foo is a symlink to foo-bar. I want to be able to type f+TAB (pretend these are the only two commands on the path that begin with f) and have one of them be completed (meaning the full name and the space after).

What ends up happening though is that it completes to just foo (no space) because of foo-bar. It's obviously not much work to then just hit the space bar, but this interrupts my flow.

Some additional details:

  • foo and foo-bar are in the same directory.
  • Deleting/moving foo isn't an option (I've hidden some details).

Is there a way to ignore a specific path entry?

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-04-27 04:00

You use FIGNORE, although it has some strange properties.

FIGNORE requires a proper suffix. So to ignore foo-bar, any of these will work:

FIGNORE=bar
FIGNORE=-bar
FIGNORE=r
FIGNORE=oo-bar

The import thing is not to try FIGNORE=foo-bar since it's not a proper suffix.

查看更多
甜甜的少女心
3楼-- · 2019-04-27 04:03

Give this a try:

FIGNORE=foo-bar
查看更多
登录 后发表回答