How do I get bash completion to work with aliases?

后端 未结 12 1058
温柔的废话
温柔的废话 2020-11-28 00:35

Case in point:

I\'m a on mac with bash v3.2.17, I\'m using git installed via macports with the bash_completion variant.

When I type git checkout m<

12条回答
  •  借酒劲吻你
    2020-11-28 01:23

    You just have to find the complete command and duplicate the line having the alias name instead.

    I have alias d-m="docker-machine". In words, d-m shall be the alias for docker-machine.

    So on Mac (via brew), the completion files are in cd `brew --prefix`/etc/bash_completion.d/.
    For my case I edited the file called docker-machine.
    All the way at the bottom there was:

    complete -F _docker_machine docker-machine
    

    So I just added another line, with my alias:

    complete -F _docker_machine docker-machine
    complete -F _docker_machine d-m
    

提交回复
热议问题