chruby: add "system" to completion list if available (#5280)
Detect system Ruby in default `PATH`, and provide "system" completion if found.
Tested with [the Dockerfile](https://gist.github.com/franklinyu/b8deda6a5093a17b575679b5808b371f).
Diff
1diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh
2index 998d92098fa5f9cac16da21c370238ea96373541..f7fedb5f250cc9bdab4642230fe063b0f6c6e9e0 100644
3--- a/plugins/chruby/chruby.plugin.zsh
4+++ b/plugins/chruby/chruby.plugin.zsh
5@@ -111,5 +111,11 @@ function chruby_prompt_info() {
6 }
7 8 # complete on installed rubies
9-_chruby() { compadd $(chruby | tr -d '* ') }
10+_chruby() {
11+ compadd $(chruby | tr -d '* ')
12+ local default_path='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'
13+ if PATH=${default_path} type ruby &> /dev/null; then
14+ compadd system
15+ fi
16+}
17 compdef _chruby chruby