-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathruby.sh
48 lines (45 loc) · 981 Bytes
/
ruby.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
alias b='bundle check || bundle'
alias bo='bundle open'
alias be='bundle exec'
alias cap='bundle exec cap'
function rake
{
if [ -S .zeus.sock ]; then
zeus rake "$@"
elif [ -e bin/rake ]; then
bin/rake "$@"
elif [ -f Gemfile ]; then
bundle exec rake "$@"
else
command rake "$@"
fi
}
function _bundle_spec_names() {
ruby <<-RUBY
NAME_VERSION = '(?! )(.*?)(?: \(([^-]*)(?:-(.*))?\))?'
File.open 'Gemfile.lock' do |io|
in_specs = false
io.lines.each do |line|
line.chomp!
case
when in_specs && line == ''
in_specs = false
when line =~ /^ +specs:\$/
in_specs = true
when in_specs && line =~ %r{^ +#{NAME_VERSION}\$}
puts \$1
end
end
end
RUBY
}
function _bundle_open() {
local curw
COMPREPLY=()
curw=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -W '$(_bundle_spec_names)' -- $curw));
return 0
}
if type complete > /dev/null 2>&1; then
complete -F _bundle_open bo
fi