public
Description: A few little scripts I keep in my ~/bin
Homepage:
Clone URL: git://github.com/eremite/binfiles.git
binfiles / zvim_rails_ide
100755 54 lines (48 sloc) 1.683 kb
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
49
50
51
52
53
54
#!/usr/bin/env ruby
 
if ARGV.size.zero?
  puts "Usage: #{File.basename($0)} name_of_project"
  exit
end
 
RAILS_ROOT = File.join(Dir.pwd, ARGV[0])
RAILS_ROOT << '/' unless RAILS_ROOT[0] =~ %r{/$}
 
unless File.exists?(RAILS_ROOT)
  puts "#{RAILS_ROOT}: No such file or directory"
  exit
end
 
ls = "ls --color"
scm = File.exists?("#{RAILS_ROOT}/.git") ? 'git status' : 'svn status'
test_dir = File.exists?("#{RAILS_ROOT}spec") ? 'spec' : 'test'
locales = File.exists?("#{RAILS_ROOT}config/locales") ? 'config/locales' : ''
 
[
  {
    :geometry => "140x38+90+270",
    :tabs => [
      {:path => "app/models", :command => ls},
      {:path => "app/views", :command => ls},
      {:path => "app/controllers", :command => ls},
      {:path => "app/helpers", :command => ls},
      {:path => "public", :command => ls},
      {:path => "public/javascripts", :command => ls},
      {:path => "vendor", :command => ls},
      {:path => test_dir, :command => ls},
      {:path => test_dir, :command => ls},
    ]
  },
  {
    :geometry => "141x32+185+110",
    :tabs => [
      {:path => "", :command => scm},
      {:path => "", :command => ls},
      {:path => "lib", :command => ls},
      {:path => "", :command => "ruby script/console"},
      {:path => "", :command => ls},
      {:path => locales, :command => ls},
      {:path => "", :command => ls},
      {:path => "", :command => ls},
      {:path => "", :command => ls}
    ]
  }
].each do |window|
  tabs = window[:tabs].map {|tab| "--tab-with-profile=DEFAULT --working-directory='#{RAILS_ROOT}#{tab[:path]}' -e \"bash -c '#{tab[:command]}; bash'\""}.join(' ')
  system "gnome-terminal --geometry #{window[:geometry]} #{tabs}"
end