showterm 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/showterm +62 -13
- data/lib/showterm.rb +4 -9
- data/showterm.gemspec +1 -1
- metadata +37 -19
data/bin/showterm
CHANGED
@@ -3,32 +3,81 @@
|
|
3
3
|
require 'readline'
|
4
4
|
require File.join(File.dirname(File.dirname(__FILE__)), 'lib/showterm')
|
5
5
|
|
6
|
+
if '-e' == ARGV[0]
|
7
|
+
$edit_timings = true
|
8
|
+
ARGV.shift
|
9
|
+
end
|
10
|
+
|
6
11
|
if ARGV.include?('-h') || ARGV.include?('--help')
|
7
12
|
puts <<-EOF
|
8
|
-
Usage: showterm <command to run>
|
13
|
+
Usage: showterm [-e] <command to run>
|
9
14
|
|
10
15
|
showterm will record the exact output of your session, and upload it to the
|
11
16
|
internet where it can be replayed by anyone to whom you give the URL.
|
17
|
+
|
18
|
+
You can pass `-e` as the first arg and it will allow you to edit the timings
|
19
|
+
file before uploading. This can be nice if you want to take long pauses (such
|
20
|
+
as searching an answer out) in between commands.
|
12
21
|
EOF
|
13
22
|
exit
|
14
23
|
end
|
15
24
|
|
25
|
+
def save which, data
|
26
|
+
path = "/tmp/showtime.#$$.#{which}"
|
27
|
+
File.open(path, 'w') do |f|
|
28
|
+
f.write(data)
|
29
|
+
end
|
30
|
+
path
|
31
|
+
end
|
32
|
+
|
33
|
+
def leave_trace message, sf, tf
|
34
|
+
script_path = save 'script', sf
|
35
|
+
times_path = save 'times', tf
|
36
|
+
puts message
|
37
|
+
puts %(your work is safe in "#{script_path}" and "#{times_path}")
|
38
|
+
puts "To try uploading manually, use:"
|
39
|
+
puts %(ruby -rshowterm -e'Showterm.upload! File.read("/tmp/showtime.#$$.script"), File.read("/tmp/showtime.#$$.times")')
|
40
|
+
end
|
41
|
+
|
42
|
+
puts 'showterm recording. (Exit shell when done.)'
|
16
43
|
sf, tf = Showterm.record! *ARGV
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
44
|
+
puts 'showterm recording finished.'
|
45
|
+
|
46
|
+
if $edit_timings
|
47
|
+
editor = ENV.fetch('VISUAL', ENV.fetch('EDITOR', 'vim'))
|
48
|
+
tips = if 'vim' == editor
|
49
|
+
<<-TIPS
|
50
|
+
Hot vim tips:
|
51
|
+
Use :cq from vim to exit nonzero, and cancel the upload
|
52
|
+
Use :%s/^[0-9]\./0./ to get rid of all longish pauses.
|
53
|
+
TIPS
|
54
|
+
else
|
55
|
+
<<-CONSOLATION_TIPS
|
56
|
+
If you can make your editor return nonzero, it will cancel the upload.
|
57
|
+
CONSOLATION_TIPS
|
22
58
|
end
|
59
|
+
puts <<-TEXT
|
23
60
|
|
24
|
-
|
25
|
-
|
61
|
+
Recording done, now it's time to dress up those timings!
|
62
|
+
#{tips}
|
63
|
+
[Hit Enter to edit]
|
64
|
+
TEXT
|
65
|
+
$stdin.readline
|
66
|
+
times_path = save 'times', tf
|
67
|
+
success = system(editor, times_path)
|
68
|
+
if success
|
69
|
+
tf = File.read(times_path)
|
70
|
+
else
|
71
|
+
leave_trace "OK, discarding edits and skipping upload.", sf, tf
|
72
|
+
exit 1
|
26
73
|
end
|
74
|
+
end
|
75
|
+
|
76
|
+
begin
|
77
|
+
puts "Uploading..."
|
78
|
+
puts Showterm.upload! sf, tf
|
79
|
+
rescue => e
|
27
80
|
puts [e] + e.backtrace
|
28
81
|
puts "-" * 80
|
29
|
-
|
30
|
-
puts %(your work is safe in "/tmp/showtime.#$$.script" and "/tmp/showtime.#$$.times")
|
31
|
-
puts "To try uploading manually use:"
|
32
|
-
|
33
|
-
puts %(ruby -rshowterm -e'Showterm.upload! File.read("/tmp/showtime.#$$.script"), File.read("/tmp/showtime.#$$.times")')
|
82
|
+
leave_trace "DON'T PANIC", sf, tf
|
34
83
|
end
|
data/lib/showterm.rb
CHANGED
@@ -13,15 +13,11 @@ module Showterm
|
|
13
13
|
# @param [*String] cmd
|
14
14
|
# @return [scriptfile, timingfile] the two halves of a termshow
|
15
15
|
def record!(*cmd)
|
16
|
-
if use_script?
|
17
|
-
|
18
|
-
ret = record_with_script(*cmd)
|
16
|
+
ret = if use_script?
|
17
|
+
record_with_script(*cmd)
|
19
18
|
else
|
20
|
-
|
21
|
-
ret = record_with_ttyrec(*cmd)
|
19
|
+
record_with_ttyrec(*cmd)
|
22
20
|
end
|
23
|
-
puts 'showterm recording finished, uploading...'
|
24
|
-
|
25
21
|
ret
|
26
22
|
end
|
27
23
|
|
@@ -39,7 +35,6 @@ module Showterm
|
|
39
35
|
# @param [String] timingfile The timings
|
40
36
|
# @param [Integer] cols The width of the terminal
|
41
37
|
def upload!(scriptfile, timingfile, cols=terminal_width)
|
42
|
-
retried = false
|
43
38
|
request = Net::HTTP::Post.new("/scripts")
|
44
39
|
request.set_form_data(:scriptfile => scriptfile,
|
45
40
|
:timingfile => timingfile,
|
@@ -47,7 +42,7 @@ module Showterm
|
|
47
42
|
|
48
43
|
response = http(request)
|
49
44
|
raise response.body unless Net::HTTPSuccess === response
|
50
|
-
|
45
|
+
response.body
|
51
46
|
rescue => e
|
52
47
|
raise if retried
|
53
48
|
retried = true
|
data/showterm.gemspec
CHANGED
metadata
CHANGED
@@ -1,24 +1,32 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: showterm
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 7
|
10
|
+
version: 0.2.7
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Conrad Irwin
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2012-11-06 00:00:00 Z
|
13
19
|
dependencies: []
|
20
|
+
|
14
21
|
description: Integrates with showterm.io for awesome sharability.
|
15
22
|
email: conrad.irwin@gmail.com
|
16
|
-
executables:
|
23
|
+
executables:
|
17
24
|
- showterm
|
18
|
-
extensions:
|
25
|
+
extensions:
|
19
26
|
- ext/extconf.rb
|
20
27
|
extra_rdoc_files: []
|
21
|
-
|
28
|
+
|
29
|
+
files:
|
22
30
|
- LICENSE.MIT
|
23
31
|
- README.md
|
24
32
|
- bin/showterm
|
@@ -38,27 +46,37 @@ files:
|
|
38
46
|
- showterm.gemspec
|
39
47
|
homepage: http://github.com/Conradirwin/showterm
|
40
48
|
licenses: []
|
49
|
+
|
41
50
|
post_install_message:
|
42
51
|
rdoc_options: []
|
43
|
-
|
52
|
+
|
53
|
+
require_paths:
|
44
54
|
- lib
|
45
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
56
|
none: false
|
47
|
-
requirements:
|
48
|
-
- -
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
|
51
|
-
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
65
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
57
73
|
requirements: []
|
74
|
+
|
58
75
|
rubyforge_project:
|
59
76
|
rubygems_version: 1.8.24
|
60
77
|
signing_key:
|
61
78
|
specification_version: 3
|
62
79
|
summary: Allows you to make screen casts of your terminal really easily
|
63
80
|
test_files: []
|
81
|
+
|
64
82
|
has_rdoc:
|