Sha256: 1d2489eb1712b868cda1ff6cec8207eb39980b54090acaa5649ccfe7efb0be14
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
#!/usr/bin/env ruby require 'paint' require 'open3' lib = File.expand_path('../../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'shellplay' continue = true sleeptime = 1.0/48.0 session = Shellplay::Session.new prompt = "\e[36mrecord >\e[0m" while continue do printf("\e[36mrecord >\e[33m %d > \e[0m", session.pointer) command = STDIN.gets.strip case command when "q" session.save puts "\nRecord ended.\n" continue = false when "d" if session.pointer == 0 puts "There is no screen to delete." else session.drop_last_screen end else displaycommand = true playprompt = true if command[0] == '#' command = command[1..-1].strip displaycommand = false if command[0] == '#' command = command[1..-1].strip playprompt = false end end start_time = Time.now Open3.popen3("bash","-l","-c",command) do |i, o, e, t| screen = Shellplay::Screen.new out = o.read err = e.read end_time = Time.now elapsed = end_time - start_time session.add_screen({ 'displaycommand' => displaycommand, 'playprompt' => playprompt, 'stdin' => command, 'stdout' => out, 'stderr' => err, 'timespent' => elapsed }) out.split("\n").each do |line| puts line sleep sleeptime end err.split("\n").each do |line| puts Paint[line, :red] end end session.next end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shellplay-0.0.4 | bin/shellrecord |