root/lang/ruby/misc/vif @ 5634

Revision 5634, 0.8 kB (checked in by ujihisa, 6 years ago)

lang/ruby/misc/vif: add excluded directory name

  • Property svn:executable set to *
Line 
1#!/usr/bin/env ruby
2
3EDITOR = ENV['EDITOR'] || 'vim '
4
5EXCLUDE_EXTENTSONS = %w(jpg png)
6EXCLUDE_FROM_CURRENT = %w(estraier tmp log coverage)
7
8ext      = EXCLUDE_EXTENTSONS.map{|ext| "! -name '*.#{ext}' "}.join
9current  = EXCLUDE_FROM_CURRENT.map{|name| "! -path './#{name}/*' "}.join
10patterns = ARGV.map{|v| "#{/^-/ === v ? '!' : ''} -path '*#{v.sub(/^-/, '')}*' "}.join
11
12files = `find . -type f #{ext} #{current} ! -path '*/.svn/*' #{patterns}`.split
13
14if files.empty?
15  filename = ARGV[0].split(/\//).map{|v| "#{v}*"}.join("/")
16  files = Dir.glob(filename)
17  files.reject!{|path| File.directory?(path)}
18end
19
20unless files.empty?
21  if /vim/ =~ EDITOR and files.size <= 4
22    system("#{EDITOR} -O #{files.join(' ')}")
23  else
24    system("#{EDITOR} #{files.join(' ')}")
25  end
26  puts files
27else
28  $stderr.puts "Not found"
29end
Note: See TracBrowser for help on using the browser.