termdump 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4837eea42355201b14f0cee3c1181f50e1f7a06a
4
+ data.tar.gz: 953466fc7b97cd9bea4a765df361438d017f79e8
5
+ SHA512:
6
+ metadata.gz: b96f0653fde8b878bde672c3e230752521e45958cd20020d24e6d9fb6fb3d1b3eb57baa4f0c0ead2a395a968c6ea1e93e399436394509b8cf35ae54dbcd58a74
7
+ data.tar.gz: c130b998cb570f3b839d43c25277a50402ab7ffdb0952a83755946b15eea106c050ae795a01ec1351742d3a47fc6ebbabc7a9bed050ba3875c926207c36b20f3
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # termdump
2
+
3
+ [![Build Status](https://travis-ci.org/spacewander/termdump.svg?branch=master)](http://travis-ci.org/spacewander/termdump)
4
+
5
+ Dump your (pseudo)terminal session and replay it. You can use it to bootstrap daily work.
6
+
7
+ ## Usage
8
+
9
+ ```shell
10
+ Usage: termdump [options] [session]
11
+ -i, --init initialize configure interactively
12
+ -e, --edit [session] edit session
13
+ -d, --delete [session] delete session
14
+ -s, --save [session] save session
15
+ --stdout print dump result to stdout while saving a session
16
+ --exclude exclude current pty while saving a session
17
+ -l, --list list all sessions
18
+ -v, --version print version
19
+ ```
20
+
21
+ ### initialize configure
22
+
23
+ ```shell
24
+ $ termdump -i
25
+ ```
26
+
27
+ ### dump a session
28
+
29
+ ```shell
30
+ $ termdump -s mydailywork
31
+ # or `termdump -s mydailywork --exclude`
32
+ # if you want to exclude the pty running this command
33
+ ```
34
+
35
+ ### load a session
36
+
37
+ ```shell
38
+ $ termdump mydailywork
39
+ ```
40
+
41
+ ### edit a session
42
+
43
+ ```shell
44
+ $ termdump -e mydailywork
45
+ ```
46
+
47
+ ### delete a session
48
+
49
+ ```shell
50
+ $ termdump -d mydailywork
51
+ ```
52
+
53
+ Read more in [session syntax and examples](sessions.md) and [configure](configure.md).
54
+
55
+ ## Supported terminal
56
+
57
+ - [x] gnome-terminal
58
+ - [x] terminator
59
+ - [x] xterm
60
+ - [x] guake
61
+ - [ ] urxvt
62
+ - [ ] konsole
63
+ - [ ] xfce4-terminal
64
+
65
+ If you want to support Terminal X, you can write a terminal file under
66
+ https://github.com/spacewander/termdump/tree/master/lib/termdump/terminal and then send me a pr.
67
+ Currently there is not a plan to support terminals in OS X platform, since I don't have OS X to test with.
68
+ If you want to implement one, you may need to use [cliclick](https://github.com/BlueM/cliclick) instead of `xdotool`.
69
+
70
+ ## Requirements
71
+
72
+ Current requirements are `ps` and `xdotool`.
73
+ We use `ps` to get the result of terminal session, and `xdotool` to emulate typing.
74
+
75
+ `ps` has been shipped with your OS probably.
76
+ You can install `xdotool` via [this guide](http://www.semicomplete.com/projects/xdotool/#idp9392).
77
+
78
+ ## Video
79
+
80
+ TODO
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env rake
2
+ # encoding: UTF-8
3
+
4
+ require 'rake'
5
+ require 'rake/testtask'
6
+
7
+ Rake::TestTask.new do |t|
8
+ t.libs << 'lib'
9
+ t.libs << 'test'
10
+ t.pattern = 'test/**/test_*.rb'
11
+ t.verbose = false
12
+ # so we can type `rake TEST="xxx"` instead of `rake TEST="test/test_xxx.rb"`
13
+ test = ENV['TEST']
14
+ unless test.nil?
15
+ ENV['TEST'] = 'test/test_' + test unless test.start_with? 'test/test_'
16
+ ENV['TEST'] += '.rb' unless test.end_with? '.rb'
17
+ end
18
+ end
19
+
20
+ task :default => :test
data/bin/termdump ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+ $:.unshift File.dirname(__FILE__) + '/../lib'
4
+ require 'termdump'
5
+
6
+ TermDump::Command.new(ARGV).run
data/etc/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env rake
2
+ # encoding: UTF-8
3
+
4
+ require 'rake'
5
+ require 'fileutils'
6
+
7
+ task :prepare do
8
+ bash_completion_dir = '/etc/bash_completion.d'
9
+ if Dir.exist?(bash_completion_dir)
10
+ FileUtils.cp './termdump', bash_completion_dir
11
+ end
12
+ #FileUtils.cp './_termdump', '/usr/share/zsh/functions/Completion/_termdump'
13
+
14
+ man_page_dir = '/usr/share/man/man1'
15
+ if Dir.exist?(man_page_dir)
16
+ FileUtils.cp 'termdump.1', man_page_dir
17
+ end
18
+ end
19
+ task :default => :prepare
data/etc/_termdump ADDED
@@ -0,0 +1,25 @@
1
+ #compdef termdump
2
+
3
+ local state session_dir
4
+ session_dir="(~/.config/termdump/session/)"
5
+
6
+ _arguments \
7
+ {-i,--init}'[initialize configure interactively]' \
8
+ {-e,--edit}'[edit session]: :->session' \
9
+ {-d,--delete}'[delete session]: :->session' \
10
+ {-s,--save}'[save session]: :->save' \
11
+ {-l,--list}'[list all sessions]' \
12
+ {-v,--version}'[print version]' \
13
+ {-h,--help}'[show usage message]' \
14
+ '*:load session:->session' && return 0
15
+
16
+ case "$state" in
17
+ session )
18
+ _files -W ${session_dir} -g '*.yml(:t:r)'
19
+ ;;
20
+ save )
21
+ _arguments \
22
+ '--exclude[exclude current pty while saving a session]' \
23
+ '--stdout[print dump result to stdout while saving a session]' \
24
+ '*:save session:_files -W ${session_dir} -g "*.yml(:t:r)"'
25
+ esac
data/etc/man.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ pandoc -s -t man termdump.1.md -o termdump.1
data/etc/termdump ADDED
@@ -0,0 +1,47 @@
1
+ # bash completion script for termdump
2
+ _termdump() {
3
+ local pre cur
4
+
5
+ COMPREPLY=()
6
+ pre=${COMP_WORDS[COMP_CWORD-1]}
7
+ cur=${COMP_WORDS[COMP_CWORD]}
8
+
9
+ list_session_dir() {
10
+ find ~/.config/termdump/session/ -iname '*.yml' -exec basename -s '.yml' {} \;
11
+ }
12
+
13
+ case "$pre" in
14
+ -e|--edit|-d|--delete )
15
+ COMPREPLY=( $( compgen -W "$(list_session_dir)" ) )
16
+ return 0
17
+ ;;
18
+ -i )
19
+ return 0
20
+ ;;
21
+ -l|--list )
22
+ COMPREPLY=( $( compgen -W "-d --delete -e --edit" ) )
23
+ return 0
24
+ ;;
25
+ -s )
26
+ COMPREPLY=( $( compgen -W "--exclude --stdout" -- $cur ) )
27
+ COMPREPLY+=( $( compgen -W "$(list_session_dir)" -- $cur ) )
28
+ return 0
29
+ esac
30
+
31
+ complete_options() {
32
+ local opts
33
+ opts='-i --init -d --delete -e --edit -h --help -l --list -s --save
34
+ -v --version'
35
+ echo "$opts"
36
+ }
37
+
38
+ case "$cur" in
39
+ -* )
40
+ COMPREPLY=( $( compgen -W "$(complete_options)" -- $cur ) )
41
+ ;;
42
+ * )
43
+ COMPREPLY=( $( compgen -W "$(complete_options)" -- $cur ) )
44
+ COMPREPLY+=( $( compgen -W "$(list_session_dir)" -- $cur ) )
45
+ esac
46
+ }
47
+ complete -F _termdump filenames termdump
data/etc/termdump.1 ADDED
@@ -0,0 +1,79 @@
1
+ .TH "TERMDUMP" "1" "Jul 17, 2015" "Termdump User Manuals" ""
2
+ .SH NAME
3
+ .PP
4
+ termdump \-\- Dump your pty session and replay it
5
+ .SH SYNOPSIS
6
+ .PP
7
+ termdump [\f[I]option\f[]] [\f[I]session\f[]]
8
+ .SH DESCRIPTION
9
+ .PP
10
+ Dump your (pseudo)terminal session and replay it.
11
+ You can use it to bootstrap daily work.
12
+ .SH OPTIONS
13
+ .TP
14
+ .B \-h, \-\-help
15
+ output usage information
16
+ .RS
17
+ .RE
18
+ .TP
19
+ .B \-i, \-\-init
20
+ initialize configure interactively
21
+ .RS
22
+ .RE
23
+ .TP
24
+ .B \-e, \-\-edit \f[I]session\f[]
25
+ edit session
26
+ .RS
27
+ .RE
28
+ .TP
29
+ .B \-d, \-\-delete \f[I]session\f[]
30
+ delete session
31
+ .RS
32
+ .RE
33
+ .TP
34
+ .B \-s, \-\-save \f[I]session\f[]
35
+ save session
36
+ .RS
37
+ .RE
38
+ .TP
39
+ .B \-l, \-\-list
40
+ list all sessions
41
+ .RS
42
+ .RE
43
+ .TP
44
+ .B \-v, \-\-version
45
+ print version
46
+ .RS
47
+ .RE
48
+ .PP
49
+ If you run \f[C]termdump\f[] with a session name only, it will replay
50
+ the session.
51
+ .SH SAVE OPTIONS
52
+ .TP
53
+ .B \-\-stdout
54
+ print dump result to stdout while saving a session
55
+ .RS
56
+ .RE
57
+ .TP
58
+ .B \-\-exclude
59
+ exclude current pty while saving a session
60
+ .RS
61
+ .RE
62
+ .SH EXAMPLE
63
+ .PP
64
+ At the first time you use this tool, you may need to run
65
+ \f[C]termdump\ \-i\f[] to set up configure.
66
+ .PP
67
+ Then you can run \f[C]termdump\ \-s\ [\-\-exclude]\f[] to save your
68
+ current pty session.
69
+ .PP
70
+ Run \f[C]termdump\ \-l\f[] to list all saved sessions,
71
+ \f[C]termdump\ \-e\f[] to edit one, and \f[C]termdump\ \-d\f[] to delete
72
+ one.
73
+ .PP
74
+ To replay your session, you can run \f[C]termdump\ [session]\f[].
75
+ .SH REPORTING BUGS
76
+ .PP
77
+ <https://github.com/spacewander/termdump/issues>
78
+ .SH AUTHORS
79
+ spacewander <spacewanderlzx@gmail.com>.
data/etc/termdump.1.md ADDED
@@ -0,0 +1,61 @@
1
+ % TERMDUMP(1) Termdump User Manuals
2
+ % spacewander <spacewanderlzx@gmail.com>
3
+ % Jul 17, 2015
4
+
5
+ # NAME
6
+ termdump -- Dump your pty session and replay it
7
+
8
+ # SYNOPSIS
9
+
10
+ termdump [*option*] [*session*]
11
+
12
+ # DESCRIPTION
13
+
14
+ Dump your (pseudo)terminal session and replay it. You can use it to bootstrap daily work.
15
+
16
+ # OPTIONS
17
+
18
+ -h, --help
19
+ : output usage information
20
+
21
+ -i, --init
22
+ : initialize configure interactively
23
+
24
+ -e, --edit *session*
25
+ : edit session
26
+
27
+ -d, --delete *session*
28
+ : delete session
29
+
30
+ -s, --save *session*
31
+ : save session
32
+
33
+ -l, --list
34
+ : list all sessions
35
+
36
+ -v, --version
37
+ : print version
38
+
39
+ If you run `termdump` with a session name only, it will replay the session.
40
+
41
+ # SAVE OPTIONS
42
+
43
+ --stdout
44
+ : print dump result to stdout while saving a session
45
+
46
+ --exclude
47
+ : exclude current pty while saving a session
48
+
49
+ # EXAMPLE
50
+
51
+ At the first time you use this tool, you may need to run `termdump -i` to set up configure.
52
+
53
+ Then you can run `termdump -s [--exclude]` to save your current pty session.
54
+
55
+ Run `termdump -l` to list all saved sessions, `termdump -e` to edit one, and `termdump -d` to delete one.
56
+
57
+ To replay your session, you can run `termdump [session]`.
58
+
59
+ # REPORTING BUGS
60
+
61
+ <https://github.com/spacewander/termdump/issues>
@@ -0,0 +1,81 @@
1
+ require 'ostruct'
2
+ require 'optparse'
3
+
4
+ require 'termdump/main'
5
+ require 'termdump/version'
6
+
7
+ module TermDump
8
+ class Command
9
+ def initialize args
10
+ @args = OpenStruct.new(:stdout => false, :action => :load, :list => false,
11
+ :session => '', :exclude => false)
12
+ OptionParser.new do |opts|
13
+ opts.banner = "Usage: termdump [options] [session]"
14
+ opts.on('-i', '--init', 'initialize configure interactively') {
15
+ @args.action = :init
16
+ }
17
+ opts.on('-e', '--edit [session]', 'edit session') do |name|
18
+ @args.action = :edit
19
+ name.nil? ? @args.list = true : @args.session = name
20
+ end
21
+ opts.on('-d', '--delete [session]', 'delete session') do |name|
22
+ @args.action = :delete
23
+ name.nil? ? @args.list = true : @args.session = name
24
+ end
25
+ opts.on('-s', '--save [session]', 'save session') do |name|
26
+ @args.action = :save
27
+ name.nil? ? @args.list = true : @args.session = name
28
+ end
29
+
30
+ opts.on_tail('--stdout', 'print dump result to stdout while saving a session') {
31
+ @args.stdout = true
32
+ }
33
+ opts.on_tail('--exclude', 'exclude current pty while saving a session') {
34
+ @args.exclude = true
35
+ }
36
+ opts.on_tail('-l', '--list', 'list all sessions') {
37
+ @args.list = true
38
+ }
39
+ opts.on_tail('-v', '--version', 'print version') do
40
+ puts VERSION
41
+ exit 0
42
+ end
43
+ opts.parse! args
44
+
45
+ # :load is the default action if no option given
46
+ if @args.action == :load
47
+ args.size > 0 ? @args.session = args[0] : @args.list = true
48
+ end
49
+ # --stdout should be used with --save
50
+ if @args.stdout || @args.exclude
51
+ if @args.action != :save
52
+ puts opts.help
53
+ exit 1
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ def run
60
+ main = Main.new
61
+ if @args.action == :save
62
+ main.save @args.session, @args.stdout, @args.exclude
63
+ elsif @args.action == :init
64
+ main.init
65
+ elsif @args.list
66
+ main.list @args.action
67
+ else
68
+ name = @args.session
69
+ case @args.action
70
+ when :delete
71
+ main.delete_session name
72
+ when :edit
73
+ main.edit_session name
74
+ when :load
75
+ main.load_session name
76
+ end
77
+ end
78
+ end
79
+
80
+ end
81
+ end