0

I define ag as bash function, to make usage relatively transparent

ag() { [ $# -gt 0 ] && vim -c silent\ SyntasticToggleMode -c copen -q <(/usr/bin/ag --silent --vimgrep --nogroup "$@") || /usr/bin/ag; }

This works fine, but if I try to TAB-complete filename, vim gets executed immediately and it gets stuck with

$ [git:master] ag sense<TAB>
Vim: Warning: Output is not to a terminal

Only way out is to kill stuck vim process from another shell.

What's going wrong here and how can this bash function be upgraded (or find some alternative) to make it TAB-completion compatible ?

EDIT ag doesn't ship any upstream completion

$ [git:master] complete -p ag
-bash: complete: ag: no completion specification
filbranden
  • 21,113
  • 3
  • 58
  • 84
lkraav
  • 1,161
  • 2
  • 11
  • 20
  • 2
    This is most likely not related to Vim, but to how your bash shell is programmed to complete the `ag` command... Can you check the output of `complete -p ag` and [edit] your question to include it? – filbranden May 09 '21 at 19:12
  • 1
    PS instead of hardcoding the path to ag you can use `command ag`, and `T && X || Y` is not the same as an if-then-else (consider what happens when T succeeds but X fails). But agreed with filbranden: if the completer tries to run ag to get completion candidates, that’s going to cause problems – D. Ben Knoble May 09 '21 at 22:15
  • Thanks for tips. `ag: no completion specification` is current state. Will update to `command` itmw here. – lkraav May 10 '21 at 07:54
  • 1
    In any case, this is about shell completion and not really about Vim... Vim is only getting involved here because you're using it in your function and the function seems to be called during completion. I'm leaning towards migrating this question to [unix.se] where they'll know more about shell completion. – filbranden May 10 '21 at 17:13

0 Answers0