tweemux 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemspec +1 -1
- data/Gemfile +1 -1
- data/README.md +63 -0
- data/img/tweemux.blend +0 -0
- data/img/tweemux.png +0 -0
- data/lib/tweemux/action/at.rb +7 -3
- data/lib/tweemux/action/keys.rb +3 -0
- data/lib/tweemux/action.rb +14 -5
- data/lib/tweemux/version.rb +1 -1
- data/test/ok18.rb +1 -0
- data/test/tweemux/action/at_test.rb +1 -1
- data/test/tweemux_test.rb +7 -1
- metadata +15 -9
- data/README.rdoc +0 -49
- data/lib/tweemux/action/bro.rb +0 -3
- data/lib/tweemux/action/sis.rb +0 -2
data/.gemspec
CHANGED
@@ -7,7 +7,7 @@ Working.gemspec(
|
|
7
7
|
:name => 'tweemux',
|
8
8
|
:summary => Working.third_line_of_readme,
|
9
9
|
#:description => Working.readme_snippet(/== Usage/, /== TODO/),
|
10
|
-
:description =>
|
10
|
+
:description => Working.third_line_of_readme,
|
11
11
|
:version => Tweemux::VERSION,
|
12
12
|
:authors => %w(☈king),
|
13
13
|
:email => 'rking-tweemux@sharpsaw.org',
|
data/Gemfile
CHANGED
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
![tweemux: For Remote Pair Programming](img/tweemux.png)
|
2
|
+
|
3
|
+
For Remote Pair Programming: A handy script to create-or-join a world-readable tmux session
|
4
|
+
|
5
|
+
One of the aims of this script is to be convenient. Another of its aims is to be transparent (read: loud) about what it's doing. None of the parts of this are inherently complicated, and we'd like to make sure you can wean yourself off of this if you ever want to.
|
6
|
+
|
7
|
+
## Problem
|
8
|
+
|
9
|
+
Though tmux is an amazing tool, some of the setup for a shared session over the Internet can be tricky, at first. As you will see from the commands output of this script, it is not utterly difficult, but it's still usually more than you want you or your pair to think about when you're trying to work.
|
10
|
+
|
11
|
+
## Guest Usage
|
12
|
+
|
13
|
+
gem install tweemux
|
14
|
+
tweemux at somehost.org
|
15
|
+
# or, specify a port:
|
16
|
+
tweemux at somehost.org 3322
|
17
|
+
|
18
|
+
If all goes well, that's it!
|
19
|
+
|
20
|
+
Now, time to roll up sleeves and get into the details of how to roll out a red
|
21
|
+
carpet like this for one's pair.
|
22
|
+
|
23
|
+
## Host Usage
|
24
|
+
|
25
|
+
For starters:
|
26
|
+
|
27
|
+
gem install tweemux
|
28
|
+
|
29
|
+
Then, create the user on your machine (this varies. On decent Unices, it's `adduser` or `useradd`. On OS X you can either get an [adduser-like script](https://raw.github.com/sharpsaw/mac-dots/master/bin/adduser) or do it through the System Preferences GUI).
|
30
|
+
|
31
|
+
If you're on a machine behind a firewall, you have these options:
|
32
|
+
|
33
|
+
* VPN. If you're on a business network with your pair, you probably can already `ping` each other's machines. Easy stuff, then.
|
34
|
+
* Directly open a port, such as going to your router config (perhaps at http://10.0.0.1 ?) and setting it to pass the external IP (see `curl ifconfig.me` or http://whatismyip.com ) through to your local box. This is smpler once you get it set up, as long as your location is stable and you have control over the router.
|
35
|
+
* Use a Virtual machine on the web, and you both ssh into that. Can work very well, and has other advantages (such as the ability to trash the machine all you want and just rebuild it later). The big downside is that you now have two lagged users rather than only one.
|
36
|
+
* SSH port forward. This is my favorite, but the downside is that you have to have access to a shell account somewhere public. Tweemux provides a tool for this:
|
37
|
+
|
38
|
+
In this example, sharpsaw.org is a machine that is not behind the firewall:
|
39
|
+
|
40
|
+
tweemux forward local 22 from sharpsaw.org 3322
|
41
|
+
|
42
|
+
Then, after your pair can get to your SSHD socket, finally:
|
43
|
+
|
44
|
+
tweemux host
|
45
|
+
# (now they're ready to `tweemux at <yourhost> <your-port>`)
|
46
|
+
|
47
|
+
## Going Further
|
48
|
+
|
49
|
+
It's also nice to share a windowing environment session as well. For example, the "Guest" can host a VNC that you, as the tweemux host, can then connect to. This allows you to "point" at things with the mouse, and to share web browsing, etc.
|
50
|
+
|
51
|
+
## No Public Box?
|
52
|
+
|
53
|
+
If you don't have a public SSH account (like the way I use sharpsaw.org, above), let me know ( i-am-stuck@sharpsaw.org ). We'll solve that.
|
54
|
+
|
55
|
+
## TODO
|
56
|
+
|
57
|
+
tweemux keys lwoodson # when their Github username == desired Unix username
|
58
|
+
# -or-
|
59
|
+
tweemux keys cirwin github: ConradIrwin
|
60
|
+
|
61
|
+
## Thanks to
|
62
|
+
|
63
|
+
The `wemux` script, which is similar to this, but has a different scope of features.
|
data/img/tweemux.blend
ADDED
Binary file
|
data/img/tweemux.png
ADDED
Binary file
|
data/lib/tweemux/action/at.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
class Tweemux::Action::At < Tweemux::Action
|
2
2
|
def run args
|
3
3
|
host, port = args
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
cmd = 'ssh', host
|
5
|
+
if port
|
6
|
+
cmd.push '-p'+port
|
7
|
+
port_parens = " (on port #{port})"
|
8
|
+
end
|
9
|
+
explained_run cmd + %W(-t tmux -S #{Tweemux::SOCK} attach),
|
10
|
+
"Connect to #{host}#{port_parens}, demand a pty, then attach to session"
|
7
11
|
end
|
8
12
|
end
|
data/lib/tweemux/action.rb
CHANGED
@@ -35,11 +35,11 @@ class Tweemux
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def system_or_raise cmd
|
38
|
-
system *cmd or pseudo_restarts(
|
38
|
+
system *cmd or pseudo_restarts cmd.join(' ')
|
39
39
|
end
|
40
40
|
|
41
41
|
def highlight_command arr
|
42
|
-
':Running'.color(:middle_blue) \
|
42
|
+
': Running'.color(:middle_blue) \
|
43
43
|
+ '; '.color(:gray245) \
|
44
44
|
+ colorize_tmux_command(arr)
|
45
45
|
end
|
@@ -65,13 +65,22 @@ class Tweemux
|
|
65
65
|
warn '# failed ☹'.color :error
|
66
66
|
ctrl_c = 'Ctrl+c'.color :keypress, :prompt
|
67
67
|
enter = 'Enter'.color :keypress, :prompt
|
68
|
+
letter_p = 'p'.color :keypress, :prompt
|
68
69
|
# TODO: work pry-rescue into this so we can offer a 'try-again'
|
69
70
|
# See also: https://github.com/ConradIrwin/pry-rescue/issues/29
|
70
|
-
|
71
|
-
|
71
|
+
print <<-EOT.chomp.color :prompt
|
72
|
+
To give up, hit: #{ctrl_c}
|
72
73
|
To run anyway, hit: #{enter}
|
74
|
+
To pry from here: #{letter_p}
|
75
|
+
>
|
73
76
|
EOT
|
74
|
-
$stdin.readline
|
77
|
+
answer = $stdin.readline
|
78
|
+
if answer[/p/i]
|
79
|
+
notice = 'I will be very impressed if this is useful...'
|
80
|
+
warn notice.color :error
|
81
|
+
require 'pry'
|
82
|
+
binding.pry
|
83
|
+
end
|
75
84
|
end
|
76
85
|
|
77
86
|
def load_all!
|
data/lib/tweemux/version.rb
CHANGED
data/test/ok18.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Just a file to make sure ruby18 is a working compiler
|
@@ -11,6 +11,6 @@ class Tweemux::Action::AtImplicitPortTest < MiniTest::Unit::TestCase
|
|
11
11
|
include TweemuxActionHelper
|
12
12
|
def argv; %w'at sharpsaw.org' end
|
13
13
|
def expected_commands
|
14
|
-
[ %w(ssh sharpsaw.org -
|
14
|
+
[ %w(ssh sharpsaw.org -t tmux -S /tmp/tweemux.sock attach) ]
|
15
15
|
end
|
16
16
|
end
|
data/test/tweemux_test.rb
CHANGED
@@ -2,7 +2,7 @@ require_relative 'test_helper'
|
|
2
2
|
|
3
3
|
class TweemuxTest < MiniTest::Unit::TestCase
|
4
4
|
def test_doc_claims
|
5
|
-
claimed_working = File.readlines('README.
|
5
|
+
claimed_working = File.readlines('README.md').grep /^ {4}tweemux/
|
6
6
|
claimed_working.each do |line|
|
7
7
|
line.sub! /#.*/, ''
|
8
8
|
fake_argv = line.sub(/^\s*tweemux/, '').split.map{|e| e.strip}
|
@@ -16,6 +16,8 @@ class TweemuxTest < MiniTest::Unit::TestCase
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_ruby18
|
19
|
+
return warn "Needs a working ruby18 executable in $PATH".color(:orange) \
|
20
|
+
unless ruby18ok 'test/ok18.rb'
|
19
21
|
# TODO: optimize this by running them all in one command
|
20
22
|
Dir['{bin,lib}/*.rb'].each do |e|
|
21
23
|
fail "ruby18 hates #{e}" unless "Syntax OK\n" == `ruby18 -c #{e}`
|
@@ -24,4 +26,8 @@ class TweemuxTest < MiniTest::Unit::TestCase
|
|
24
26
|
skip 'Needs ruby18 executable in $PATH' if e.message[/ruby18/]
|
25
27
|
raise e
|
26
28
|
end
|
29
|
+
|
30
|
+
def ruby18ok args
|
31
|
+
"Syntax OK\n" == `ruby18 -c #{args}`
|
32
|
+
end
|
27
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tweemux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,13 +9,16 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'For Remote Pair Programming: A handy script to create-or-join a world-readable
|
15
|
-
tmux session
|
15
|
+
tmux session
|
16
16
|
|
17
17
|
|
18
|
-
|
18
|
+
For Remote Pair Programming: A handy script to create-or-join a world-readable tmux
|
19
|
+
session
|
20
|
+
|
21
|
+
'
|
19
22
|
email: rking-tweemux@sharpsaw.org
|
20
23
|
executables:
|
21
24
|
- tweemux
|
@@ -27,20 +30,22 @@ files:
|
|
27
30
|
- Gemfile
|
28
31
|
- Guardfile
|
29
32
|
- LICENSE.txt
|
30
|
-
- README.
|
33
|
+
- README.md
|
31
34
|
- Rakefile
|
32
35
|
- bin/tweemux
|
36
|
+
- img/tweemux.blend
|
37
|
+
- img/tweemux.png
|
33
38
|
- lib/tweemux.rb
|
34
39
|
- lib/tweemux/action.rb
|
35
40
|
- lib/tweemux/action/at.rb
|
36
|
-
- lib/tweemux/action/bro.rb
|
37
41
|
- lib/tweemux/action/forward.rb
|
38
42
|
- lib/tweemux/action/host.rb
|
43
|
+
- lib/tweemux/action/keys.rb
|
39
44
|
- lib/tweemux/action/share.rb
|
40
|
-
- lib/tweemux/action/sis.rb
|
41
45
|
- lib/tweemux/core_ext.rb
|
42
46
|
- lib/tweemux/version.rb
|
43
47
|
- test/action_test_helper.rb
|
48
|
+
- test/ok18.rb
|
44
49
|
- test/test_helper.rb
|
45
50
|
- test/tweemux/action/at_test.rb
|
46
51
|
- test/tweemux/action/forward_test.rb
|
@@ -68,13 +73,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
73
|
version: '0'
|
69
74
|
requirements: []
|
70
75
|
rubyforge_project:
|
71
|
-
rubygems_version: 1.8.
|
76
|
+
rubygems_version: 1.8.23
|
72
77
|
signing_key:
|
73
78
|
specification_version: 3
|
74
79
|
summary: ! 'For Remote Pair Programming: A handy script to create-or-join a world-readable
|
75
|
-
tmux session
|
80
|
+
tmux session'
|
76
81
|
test_files:
|
77
82
|
- test/action_test_helper.rb
|
83
|
+
- test/ok18.rb
|
78
84
|
- test/test_helper.rb
|
79
85
|
- test/tweemux/action/at_test.rb
|
80
86
|
- test/tweemux/action/forward_test.rb
|
data/README.rdoc
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
= tweemux
|
2
|
-
|
3
|
-
For Remote Pair Programming: A handy script to create-or-join a world-readable tmux session (smaller than wemux)
|
4
|
-
|
5
|
-
One of the aims of this script is to be convenient. Another of its aims is to be transparent (read: loud) about what it's doing. None of the parts of this are inherently complicated, and any of them is prone to need additional debugging, so it's best that `tweemux`'s behavior is visible.
|
6
|
-
|
7
|
-
== Problem
|
8
|
-
|
9
|
-
Though tmux is an amazing tool, some of the parts of it are low-level. As you can see from the tmux portion of this script's source, there isn't much you have to do to get a shared session, but it's still more than you want you or your pair to think about when you're trying to work. The `wemux` script is similar to this, but I don't care for its complexity/optionality/config (and the thing that really bothers me is that it has a 'read-only' mode that only is read-only because of the command used to connect to the socket — the socket itself is still `chmod 777`, so you might as well be honest about the idea that the session could be connected by any user in writeable mode).
|
10
|
-
|
11
|
-
Once you've solved the "shared tmux" problem, that's actually the easier part of it. This script goes a little further and helps with the user and SSH connection problems.
|
12
|
-
|
13
|
-
== Host Usage
|
14
|
-
|
15
|
-
For starters:
|
16
|
-
|
17
|
-
gem install tweemux
|
18
|
-
|
19
|
-
Then, create the user on your machine:
|
20
|
-
|
21
|
-
tweemux bro lwoodson # when their Github username == desired Unix username
|
22
|
-
# -or-
|
23
|
-
tweemux bro cirwin github: ConradIrwin
|
24
|
-
# -or-
|
25
|
-
tweemux sis ghopper # synonym for 'bro'
|
26
|
-
|
27
|
-
If you're on a machine behind a firewall, use one that is *not* behind a firewall that you also have SSH access to (in this example, sharpsaw.org is the one not behind the firewall):
|
28
|
-
|
29
|
-
tweemux forward local 22 from sharpsaw.org 3322
|
30
|
-
# ^ Or, if you're in control of the router, you can just open a port and
|
31
|
-
# point your pair at your actual IP (`curl ifconfig.me` comes in handy for
|
32
|
-
# finding the public IP)
|
33
|
-
|
34
|
-
Then finally:
|
35
|
-
|
36
|
-
tweemux host
|
37
|
-
|
38
|
-
== Guest Usage
|
39
|
-
|
40
|
-
gem install tweemux
|
41
|
-
tweemux at sharpsaw.org 3322 # uses the 'forward' set up from above
|
42
|
-
|
43
|
-
== Going Further
|
44
|
-
|
45
|
-
It's also nice to share a windowing environment session as well. For example, the "Guest" can host a VNC that you, as the tweemux host, can then connect to. This allows you to "point" at things with the mouse, and to share web browsing, etc.
|
46
|
-
|
47
|
-
== No Public Box?
|
48
|
-
|
49
|
-
If you don't have a public SSH account (like the way I use sharpsaw.org, above), let me know ( i-am-stuck@sharpsaw.org ). We'll solve that.
|
data/lib/tweemux/action/bro.rb
DELETED
data/lib/tweemux/action/sis.rb
DELETED