Skip to content

ag bash completion not working #2

Description

@finelog

sorry to bother, from the readme, this project probably is not maintaining anymore.
but i think this problem should be brought up, in case someother became the victim.
following is the cause and solution:

  1. the file ag.bashcomp.sh name should be rename to ag in bash completions dir,
    explantion from stackoverflow: https://unix.stackexchange.com/a/717732

Completion files in /etc/bash_completion.d are always sourced immediately by bash_completion for backwards compatibility. The completions directories, on the other hand, lazily source the scripts inside, that is, a particular completion file isn't sourced until completion is requested for that command. The file to source is determined by its name, thus it must have the same name as the command you're trying to get completions for. So, for example, tmux.completion.bash should be symlinked as completions/tmux and not completions/tmux.completion.bash.

Finally, as you're putting everything else under /usr/local, note that you can put the completion scripts there as well: /usr/local/share/bash-completion/completions.

  1. the bash function _split_longopt no longer exists in bash-completion v2.16, i'm not sure in which version it was being removed though.

the simpler fix:

-  _split_longopt && split=true
+  _comp__split_longopt && split=true

the slightly more complex fix (not tested):

-  _split_longopt && split=true
+  # for newer version of bash completion
+  # _split_longopt is not available
+  # replaced by _comp__split_longopt
+  newfunc=$(type -t _comp__split_longopt)
+  if [ "$newfunc" = "function" ]; then
+      _comp__split_longopt && split=true
+  else
+      _split_longopt && split=true

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions