0

How do I read these lines?

#compdef rspec
compadd -P spec/ $(ls spec/**/*_spec.rb | sed -E "s/spec\///g")

I understand it's a completion rule for ZSH, but I'm not sure I follow what it is saying....

They come from here, https://github.com/thoughtbot/dotfiles/blob/master/zsh/completion/_rspec

Mayer
  • 23
  • 5
  • 1
    `compadd` is a `zsh` builtin - it does _not_ exist in `bash`. – mklement0 Nov 19 '15 at 03:09
  • 1
    Read the documentation of `compadd`: http://zsh.sourceforge.net/Doc/Release/Completion-Widgets.html#index-compadd Of course there's also `run-help compadd` which includes the same content. – 4ae1e1 Nov 19 '15 at 03:16
  • 1
    By the way, I think you should edit the title, which is utterly confusing and doesn't capture your question at all. There's no "piece of bash script" anywhere in your question. – 4ae1e1 Nov 19 '15 at 03:19
  • 1
    @mklement0 Oops already deleted... Anyway, I'll leave a link about `run-help` here: http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Accessing-On_002dLine-Help (and note that it is not as good as bash's `help` in that it takes you to the appropriate man page from which you need to search). – 4ae1e1 Nov 19 '15 at 04:00
  • 1
    To complement @4ae1e1's helpful link: replacing `zsh`'s default `run-help` definition (a mere alias of `man`) with `unalias run-help; autoload -Uz run-help` makes `run-help` support _builtin_ names as operands - you'll get a builtins / completion-related builtins overview page, on which, through in-page searching, you'll find a description of the builtin of interest. – mklement0 Nov 19 '15 at 04:06
  • Why (or how) would you write a zsh completion rule in bash? – chepner Nov 20 '15 at 13:33

0 Answers0