Sha256: dc6db9c583c6d9c0235638c473b7d17fcbb908a29398ef49ff365c0072f2931d
Contents?: true
Size: 1.4 KB
Versions: 7
Compression:
Stored size: 1.4 KB
Contents
#!/usr/bin/env ruby require 'spruz/go' include Spruz::GO require 'utils' include Utils require 'tempfile' def usage puts <<-EOT Usage: #{File.basename($0)} [OPTS] [PATHES] PATHES are the directory and file pathes that are opened in the vim. Options are -w open a buffer in vim and wait until it is deleted -s read files and files:linenumbers from stdin and open them -p DURATION pause for this many seconds to wait for vim's reaction -h display this help EOT exit 1 end $opt = go 'wp:sh' $opt['h'] and usage editor = Editor.new do |config| config.wait = $opt['w'] config.pause_duration = ($opt['p'] || 1).to_i end if $opt['s'] begin until STDIN.eof? line = STDIN.gets line = line.sub(/.*?([^:\s]+:)/, '\1') editor.edit(line) end rescue Interrupt end else argv = ARGV.dup if argv.empty? if !STDIN.tty? file = File.new(File.join(Dir.tmpdir, "edit_tmp.#$$"), 'w') until STDIN.eof? buffer = STDIN.read(8192) file.write buffer end file.close argv << file.path else editor.ensure_running end end unless argv.empty? if editor.file_linenumber?(argv.first) editor.wait = argv.size > 1 for current_file in argv STDOUT.puts "Edit #{current_file}" editor.edit current_file end else editor.edit(*argv) end end end exit 0
Version data entries
7 entries across 7 versions & 1 rubygems
Version | Path |
---|---|
utils-0.0.18 | bin/edit |
utils-0.0.17 | bin/edit |
utils-0.0.16 | bin/edit |
utils-0.0.15 | bin/edit |
utils-0.0.14 | bin/edit |
utils-0.0.13 | bin/edit |
utils-0.0.12 | bin/edit |