Ignore a path entry with bash tab-completion

六眼飞鱼酱① 提交于 2019-12-10 03:00:43

问题


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?


回答1:


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.




回答2:


Give this a try:

FIGNORE=foo-bar


来源:https://stackoverflow.com/questions/2225976/ignore-a-path-entry-with-bash-tab-completion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!