Sha256: c1e0e5a9829d8588574f1c71700916e05889fe7314991826ac2b1edbce4597f6
Contents?: true
Size: 1.64 KB
Versions: 6
Compression:
Stored size: 1.64 KB
Contents
#!/usr/bin/env ruby require 'tins/xt' include Tins::GO require 'utils' include Utils require 'tempfile' def usage puts <<-EOT Usage: #{File.basename($0)} [OPTS] [PATHS] PATHS are the directory and file paths 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 -m make intermediate non existing directories to file -p DURATION pause for this many seconds to wait for vim's reaction -S SERVER specify the server for this edit command -h display this help Version is #{File.basename($0)} #{Utils::VERSION}. EOT exit 1 end $opt = go 'p:S:wsmh' $opt['h'] and usage editor = Editor.new do |config| config.wait = $opt['w'] config.pause_duration = ($opt['p'] || 1).to_i s = $opt['S'] and config.servername = s config.mkdir = $opt['m'] end if $opt['s'] begin until STDIN.eof? line = STDIN.gets line = line.sub(/.*?([^:\s]+:)/, '\1') editor.edit(line) end rescue Interrupt exit 1 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
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
utils-0.0.73 | bin/edit |
utils-0.0.72 | bin/edit |
utils-0.0.71 | bin/edit |
utils-0.0.70 | bin/edit |
utils-0.0.69 | bin/edit |
utils-0.0.68 | bin/edit |