sc_tmux 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +53 -0
- data/LICENSE.txt +22 -0
- data/README.md +106 -0
- data/README.rdoc +19 -0
- data/Rakefile +66 -0
- data/bin/sc +43 -0
- data/features/sc_tmux.feature +76 -0
- data/features/step_definitions/sc_tmux_steps.rb +8 -0
- data/features/support/env.rb +16 -0
- data/lib/sc_tmux/version.rb +3 -0
- data/lib/sc_tmux.rb +80 -0
- data/sc_tmux.gemspec +28 -0
- data/spec/something_spec.rb +5 -0
- metadata +178 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
sc_tmux (0.0.1)
|
|
5
|
+
methadone (~> 1.3.1)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
aruba (0.5.3)
|
|
11
|
+
childprocess (>= 0.3.6)
|
|
12
|
+
cucumber (>= 1.1.1)
|
|
13
|
+
rspec-expectations (>= 2.7.0)
|
|
14
|
+
builder (3.2.2)
|
|
15
|
+
childprocess (0.3.9)
|
|
16
|
+
ffi (~> 1.0, >= 1.0.11)
|
|
17
|
+
cucumber (1.3.10)
|
|
18
|
+
builder (>= 2.1.2)
|
|
19
|
+
diff-lcs (>= 1.1.3)
|
|
20
|
+
gherkin (~> 2.12)
|
|
21
|
+
multi_json (>= 1.7.5, < 2.0)
|
|
22
|
+
multi_test (>= 0.0.2)
|
|
23
|
+
diff-lcs (1.2.5)
|
|
24
|
+
ffi (1.9.3)
|
|
25
|
+
gherkin (2.12.2)
|
|
26
|
+
multi_json (~> 1.3)
|
|
27
|
+
json (1.8.1)
|
|
28
|
+
methadone (1.3.1)
|
|
29
|
+
bundler
|
|
30
|
+
multi_json (1.8.2)
|
|
31
|
+
multi_test (0.0.2)
|
|
32
|
+
rake (0.9.6)
|
|
33
|
+
rdoc (4.0.1)
|
|
34
|
+
json (~> 1.4)
|
|
35
|
+
rspec (2.14.1)
|
|
36
|
+
rspec-core (~> 2.14.0)
|
|
37
|
+
rspec-expectations (~> 2.14.0)
|
|
38
|
+
rspec-mocks (~> 2.14.0)
|
|
39
|
+
rspec-core (2.14.7)
|
|
40
|
+
rspec-expectations (2.14.4)
|
|
41
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
42
|
+
rspec-mocks (2.14.4)
|
|
43
|
+
|
|
44
|
+
PLATFORMS
|
|
45
|
+
ruby
|
|
46
|
+
|
|
47
|
+
DEPENDENCIES
|
|
48
|
+
aruba
|
|
49
|
+
bundler (~> 1.3)
|
|
50
|
+
rake (~> 0.9.2)
|
|
51
|
+
rdoc
|
|
52
|
+
rspec
|
|
53
|
+
sc_tmux!
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 Aaron Nichols
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# ScTmux
|
|
2
|
+
|
|
3
|
+
### Problem
|
|
4
|
+
When I run tmux on a remote host I lose access to my ssh-agent if I
|
|
5
|
+
detach and attach again. Existing windows have old ssh-agent environment
|
|
6
|
+
values. I also like to have my tmux windows named by the host I'm
|
|
7
|
+
connecting to. This gem resolves those two problems.
|
|
8
|
+
|
|
9
|
+
### Solution
|
|
10
|
+
This script started as a set of bash scripts which made it easier to
|
|
11
|
+
refresh ssh-agent info on existing tmux windows. These are now
|
|
12
|
+
implemented as a gem which installs an 'sc' binary.
|
|
13
|
+
|
|
14
|
+
sc has a number of features:
|
|
15
|
+
|
|
16
|
+
- Collect ssh-agent vars to a file for use in other operations
|
|
17
|
+
- make current ssh-agent vars available to eval in a new shell
|
|
18
|
+
- Set the title on new tmux windows when you ssh to a host (requires you
|
|
19
|
+
use 'sc' instead of 'ssh')
|
|
20
|
+
- create new tmux sessions or attach to existing ones, runs sc -g
|
|
21
|
+
automatically when re-attaching
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
Installation is simple:
|
|
26
|
+
|
|
27
|
+
$ gem install sc_tmux
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
sc is run both with arguments to interact with tmux & your shell as well
|
|
31
|
+
as run as an ssh replacement.
|
|
32
|
+
|
|
33
|
+
### SSH Replacement
|
|
34
|
+
When run as an ssh replacement it simply
|
|
35
|
+
pulls the current ssh-agent vars into the shell (`sc -f`), outputs the
|
|
36
|
+
result of `which ssh` to show which ssh binary is being run and then
|
|
37
|
+
opens a new tmux window named after the hostname you specify to ssh to
|
|
38
|
+
the host.
|
|
39
|
+
|
|
40
|
+
Example:
|
|
41
|
+
|
|
42
|
+
$ sc somehost
|
|
43
|
+
|
|
44
|
+
or
|
|
45
|
+
|
|
46
|
+
$ sc username@somehost
|
|
47
|
+
|
|
48
|
+
### Options
|
|
49
|
+
|
|
50
|
+
`-g` Grab SSH
|
|
51
|
+
|
|
52
|
+
This stores the current ssh-agent vars to a file for later use. This
|
|
53
|
+
happens automatically if you use the `--attach` option. You may also run
|
|
54
|
+
it just before re-attaching to your tmux session.
|
|
55
|
+
|
|
56
|
+
For example, I use tmuxinator, so I have the following alias:
|
|
57
|
+
`alias mux='sc -g && mux'`
|
|
58
|
+
|
|
59
|
+
`-f` Fix SSH
|
|
60
|
+
|
|
61
|
+
This will output the current values stored by the `-g` option.
|
|
62
|
+
Unfortunately it's really only useful when used inside an alias because
|
|
63
|
+
you need to eval the contents of the file - thus I usually add the
|
|
64
|
+
following alias:
|
|
65
|
+
|
|
66
|
+
`alias fixssh='eval $(sc -f)'`
|
|
67
|
+
|
|
68
|
+
Then when you want to 'fix' ssh inside a pre-existing tmux window you
|
|
69
|
+
just type `fixssh`.
|
|
70
|
+
|
|
71
|
+
`-s` Setup
|
|
72
|
+
|
|
73
|
+
This is just a convenience method that outputs the fix alias above so
|
|
74
|
+
you can easily add it to your setup.
|
|
75
|
+
|
|
76
|
+
`-a` Attach
|
|
77
|
+
|
|
78
|
+
This will first store the current ssh-agent vars and then will attempt
|
|
79
|
+
to attach to an existing tmux session. This assumes a tmux session
|
|
80
|
+
exists with the same name as is passed by the `-n` parameter ('prod' by
|
|
81
|
+
default)
|
|
82
|
+
|
|
83
|
+
`-c` Create
|
|
84
|
+
|
|
85
|
+
This will create a new tmux session using the configured session name if
|
|
86
|
+
one doesn't already exist.
|
|
87
|
+
|
|
88
|
+
`-n` Socket Name
|
|
89
|
+
|
|
90
|
+
This will use the specified socket name when starting tmux - this allows
|
|
91
|
+
you to have multiple tmux sessions attached to different sockets.
|
|
92
|
+
|
|
93
|
+
`--agent_file` Agent file
|
|
94
|
+
|
|
95
|
+
This is the name of the file used to store the ssh-agent var values. By
|
|
96
|
+
default this filename is based on your hostname (to be compatible w/
|
|
97
|
+
shared home directories) and is listed in the help output.
|
|
98
|
+
|
|
99
|
+
## Contributing
|
|
100
|
+
|
|
101
|
+
1. Fork it
|
|
102
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
103
|
+
3. Add your tests, then add your new awesomeness
|
|
104
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
|
105
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
|
106
|
+
6. Create new Pull Request
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
= sc_tmux - DESCRIBE YOUR GEM
|
|
2
|
+
|
|
3
|
+
Author:: YOUR NAME (YOUR EMAIL)
|
|
4
|
+
Copyright:: Copyright (c) 2013 YOUR NAME
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
DESCRIBE YOUR GEM HERE
|
|
8
|
+
|
|
9
|
+
== Links
|
|
10
|
+
|
|
11
|
+
* {Source on Github}[LINK TO GITHUB]
|
|
12
|
+
* RDoc[LINK TO RDOC.INFO]
|
|
13
|
+
|
|
14
|
+
== Install
|
|
15
|
+
|
|
16
|
+
== Examples
|
|
17
|
+
|
|
18
|
+
== Contributing
|
|
19
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
def dump_load_path
|
|
2
|
+
puts $LOAD_PATH.join("\n")
|
|
3
|
+
found = nil
|
|
4
|
+
$LOAD_PATH.each do |path|
|
|
5
|
+
if File.exists?(File.join(path,"rspec"))
|
|
6
|
+
puts "Found rspec in #{path}"
|
|
7
|
+
if File.exists?(File.join(path,"rspec","core"))
|
|
8
|
+
puts "Found core"
|
|
9
|
+
if File.exists?(File.join(path,"rspec","core","rake_task"))
|
|
10
|
+
puts "Found rake_task"
|
|
11
|
+
found = path
|
|
12
|
+
else
|
|
13
|
+
puts "!! no rake_task"
|
|
14
|
+
end
|
|
15
|
+
else
|
|
16
|
+
puts "!!! no core"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
if found.nil?
|
|
21
|
+
puts "Didn't find rspec/core/rake_task anywhere"
|
|
22
|
+
else
|
|
23
|
+
puts "Found in #{path}"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
require 'bundler'
|
|
27
|
+
require 'rake/clean'
|
|
28
|
+
|
|
29
|
+
begin
|
|
30
|
+
require 'rspec/core/rake_task'
|
|
31
|
+
rescue LoadError
|
|
32
|
+
dump_load_path
|
|
33
|
+
raise
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
require 'cucumber'
|
|
37
|
+
require 'cucumber/rake/task'
|
|
38
|
+
gem 'rdoc' # we need the installed RDoc gem, not the system one
|
|
39
|
+
require 'rdoc/task'
|
|
40
|
+
|
|
41
|
+
include Rake::DSL
|
|
42
|
+
|
|
43
|
+
Bundler::GemHelper.install_tasks
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
RSpec::Core::RakeTask.new do |t|
|
|
47
|
+
# Put spec opts in a file named .rspec in root
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
CUKE_RESULTS = 'results.html'
|
|
52
|
+
CLEAN << CUKE_RESULTS
|
|
53
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
|
54
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
|
|
55
|
+
t.fork = false
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
Rake::RDocTask.new do |rd|
|
|
59
|
+
|
|
60
|
+
rd.main = "README.rdoc"
|
|
61
|
+
|
|
62
|
+
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
task :default => [:spec,:features]
|
|
66
|
+
|
data/bin/sc
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'optparse'
|
|
4
|
+
require 'methadone'
|
|
5
|
+
require 'sc_tmux.rb'
|
|
6
|
+
|
|
7
|
+
class App
|
|
8
|
+
include Methadone::Main
|
|
9
|
+
include Methadone::CLILogging
|
|
10
|
+
|
|
11
|
+
main do # Add args you want: |like,so|
|
|
12
|
+
# your program code here
|
|
13
|
+
# You can access CLI options via
|
|
14
|
+
# the options Hash
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# supplemental methods here
|
|
18
|
+
|
|
19
|
+
# Declare command-line interface here
|
|
20
|
+
|
|
21
|
+
# description "one line description of your app"
|
|
22
|
+
#
|
|
23
|
+
# Accept flags via:
|
|
24
|
+
# on("--flag VAL","Some flag")
|
|
25
|
+
# options[flag] will contain VAL
|
|
26
|
+
#
|
|
27
|
+
# Specify switches via:
|
|
28
|
+
# on("--[no-]switch","Some switch")
|
|
29
|
+
#
|
|
30
|
+
# Or, just call OptionParser methods on opts
|
|
31
|
+
#
|
|
32
|
+
# Require an argument
|
|
33
|
+
# arg :some_arg
|
|
34
|
+
#
|
|
35
|
+
# # Make an argument optional
|
|
36
|
+
# arg :optional_arg, :optional
|
|
37
|
+
|
|
38
|
+
version ScTmux::VERSION
|
|
39
|
+
|
|
40
|
+
use_log_level_option
|
|
41
|
+
|
|
42
|
+
go!
|
|
43
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Feature: My bootstrapped app kinda works
|
|
2
|
+
In order to get going on coding my awesome app
|
|
3
|
+
I want to have aruba and cucumber setup
|
|
4
|
+
So I don't have to do it myself
|
|
5
|
+
|
|
6
|
+
Scenario: App just runs
|
|
7
|
+
When I get help for "sc"
|
|
8
|
+
Then the exit status should be 0
|
|
9
|
+
And the banner should be present
|
|
10
|
+
And the banner should document that this app takes options
|
|
11
|
+
And the following options should be documented:
|
|
12
|
+
|--version|
|
|
13
|
+
|--create|
|
|
14
|
+
|--attach|
|
|
15
|
+
|--fix|
|
|
16
|
+
|--grab|
|
|
17
|
+
|--name|
|
|
18
|
+
|--agent_file|
|
|
19
|
+
|
|
20
|
+
Scenario: App provides help with no arguments
|
|
21
|
+
When I run `sc`
|
|
22
|
+
Then the exit status should be 64
|
|
23
|
+
And the banner should be present
|
|
24
|
+
And the output should contain "We expect a HOST if no options are passed"
|
|
25
|
+
|
|
26
|
+
Scenario: Grab gets variables
|
|
27
|
+
Given I set the environment variables to:
|
|
28
|
+
| SSH_CLIENT | foo |
|
|
29
|
+
| SSH_TTY | bar |
|
|
30
|
+
| SSH_AUTH_SOCK | derp |
|
|
31
|
+
| SSH_CONNECTION | perp |
|
|
32
|
+
When I run `sc -g`
|
|
33
|
+
Then the exit status should be 0
|
|
34
|
+
|
|
35
|
+
Scenario: Grab gets variables to a custom agent_file
|
|
36
|
+
Given I set the environment variables to:
|
|
37
|
+
| SSH_CLIENT | foo |
|
|
38
|
+
| SSH_TTY | bar |
|
|
39
|
+
| SSH_AUTH_SOCK | derp |
|
|
40
|
+
| SSH_CONNECTION | perp |
|
|
41
|
+
When I run `sc -g --agent_file .ag_file_test`
|
|
42
|
+
Then the exit status should be 0
|
|
43
|
+
And the file ".ag_file_test" should contain:
|
|
44
|
+
"""
|
|
45
|
+
SSH_CLIENT="foo"
|
|
46
|
+
SSH_TTY="bar"
|
|
47
|
+
SSH_AUTH_SOCK="derp"
|
|
48
|
+
SSH_CONNECTION="perp"
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
Scenario: Fix outputs variables
|
|
52
|
+
Given a file named ".ag_file_test" with:
|
|
53
|
+
"""
|
|
54
|
+
SSH_CLIENT="bark"
|
|
55
|
+
SSH_TTY="meow"
|
|
56
|
+
SSH_AUTH_SOCK="oink"
|
|
57
|
+
SSH_CONNECTION="caw"
|
|
58
|
+
"""
|
|
59
|
+
When I run `sc -f --agent_file .ag_file_test`
|
|
60
|
+
Then the output should contain:
|
|
61
|
+
"""
|
|
62
|
+
SSH_CLIENT="bark"
|
|
63
|
+
SSH_TTY="meow"
|
|
64
|
+
SSH_AUTH_SOCK="oink"
|
|
65
|
+
SSH_CONNECTION="caw"
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
Scenario: Setup outputs alias
|
|
69
|
+
When I run `sc -s`
|
|
70
|
+
Then the exit status should be 0
|
|
71
|
+
And the output should contain:
|
|
72
|
+
"""
|
|
73
|
+
Add the following alias to wherever you keep aliases:
|
|
74
|
+
alias fixssh='eval $(sc -f)'
|
|
75
|
+
"""
|
|
76
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'aruba/cucumber'
|
|
2
|
+
require 'methadone/cucumber'
|
|
3
|
+
|
|
4
|
+
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
|
5
|
+
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
|
|
6
|
+
|
|
7
|
+
Before do
|
|
8
|
+
# Using "announce" causes massive warnings on 1.9.2
|
|
9
|
+
@puts = true
|
|
10
|
+
@original_rubylib = ENV['RUBYLIB']
|
|
11
|
+
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
After do
|
|
15
|
+
ENV['RUBYLIB'] = @original_rubylib
|
|
16
|
+
end
|
data/lib/sc_tmux.rb
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require "sc_tmux/version"
|
|
2
|
+
|
|
3
|
+
module ScTmux
|
|
4
|
+
class Sc
|
|
5
|
+
include Methadone::Main
|
|
6
|
+
include Methadone::CLILogging
|
|
7
|
+
include Methadone::SH
|
|
8
|
+
version(ScTmux::VERSION)
|
|
9
|
+
|
|
10
|
+
main do |host|
|
|
11
|
+
if options[:grab]
|
|
12
|
+
grab
|
|
13
|
+
elsif options[:fix]
|
|
14
|
+
fix
|
|
15
|
+
elsif options[:create]
|
|
16
|
+
create
|
|
17
|
+
elsif options[:attach]
|
|
18
|
+
attach
|
|
19
|
+
elsif options[:setup]
|
|
20
|
+
setup
|
|
21
|
+
elsif host
|
|
22
|
+
ssh(host)
|
|
23
|
+
else
|
|
24
|
+
help_now!("We expect a HOST if no options are passed")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
description "Reattach tmux windows to ssh-agent"
|
|
30
|
+
# Defaults
|
|
31
|
+
options[:agent_file] = "#{ENV['HOME']}/.sc_agent_info-#{%x[hostname -s].chomp}"
|
|
32
|
+
options[:name] = "prod"
|
|
33
|
+
|
|
34
|
+
arg :host, :optional, "Hostname for ssh connections"
|
|
35
|
+
on("-g", "--grab", "Grab current SSH Env vars")
|
|
36
|
+
on("-c", "--create", "Create new tmux session")
|
|
37
|
+
on("-a", "--attach", "Attach to existing tmux session")
|
|
38
|
+
on("-f", "--fix", "Output vars suitable for eval to fixup current shell")
|
|
39
|
+
on("-s", "--setup", "Show pasties for final setup")
|
|
40
|
+
on("--agent_file FILENAME", "Alternate file to store agent file")
|
|
41
|
+
on("-n NAME", "--name", "Socket name to use for tmux")
|
|
42
|
+
|
|
43
|
+
def self.setup
|
|
44
|
+
puts "Add the following alias to wherever you keep aliases:"
|
|
45
|
+
puts "alias fixssh='eval $(sc -f)'"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.grab
|
|
49
|
+
File.unlink(options[:agent_file]) if File.exist?(options[:agent_file])
|
|
50
|
+
f = File.new(options[:agent_file], "w")
|
|
51
|
+
|
|
52
|
+
%w(SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION).each do |var|
|
|
53
|
+
f.write("#{var}=\"#{ENV[var]}\"\n")
|
|
54
|
+
end
|
|
55
|
+
f.close
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.fix
|
|
59
|
+
puts File.read(options[:agent_file])
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def self.ssh(host)
|
|
63
|
+
which_ssh = `which ssh`.chomp
|
|
64
|
+
display_host = /(.+@)?(([0-9]+\.){3}[0-9]+|([^.]+))/.match(host)[2]
|
|
65
|
+
sh("tmux new-window -n #{display_host} \"echo 'Using: #{which_ssh}' ; . #{options[:agent_file]} ; ssh -A #{host}\"")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def self.create
|
|
69
|
+
grab
|
|
70
|
+
sh("tmux -L #{options[:name]}")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def self.attach
|
|
74
|
+
grab
|
|
75
|
+
sh("tmux -L #{options[:name]} attach")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
go!
|
|
79
|
+
end
|
|
80
|
+
end
|
data/sc_tmux.gemspec
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'sc_tmux/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "sc_tmux"
|
|
8
|
+
spec.version = ScTmux::VERSION
|
|
9
|
+
spec.authors = ["Aaron Nichols"]
|
|
10
|
+
spec.email = ["anichols@trumped.org"]
|
|
11
|
+
spec.description = %q{Make a remote tmux play well with ssh-agent}
|
|
12
|
+
spec.summary = %q{Make a remote tmux play well with ssh-agent}
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
spec.add_development_dependency('rdoc')
|
|
24
|
+
spec.add_development_dependency('aruba')
|
|
25
|
+
spec.add_development_dependency('rake', '~> 0.9.2')
|
|
26
|
+
spec.add_dependency('methadone', '~> 1.3.1')
|
|
27
|
+
spec.add_development_dependency('rspec')
|
|
28
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sc_tmux
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Aaron Nichols
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2013-12-23 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: bundler
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ~>
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '1.3'
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ~>
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '1.3'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: rake
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: rdoc
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ! '>='
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ! '>='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: aruba
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
65
|
+
none: false
|
|
66
|
+
requirements:
|
|
67
|
+
- - ! '>='
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
type: :development
|
|
71
|
+
prerelease: false
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ! '>='
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '0'
|
|
78
|
+
- !ruby/object:Gem::Dependency
|
|
79
|
+
name: rake
|
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
|
81
|
+
none: false
|
|
82
|
+
requirements:
|
|
83
|
+
- - ~>
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: 0.9.2
|
|
86
|
+
type: :development
|
|
87
|
+
prerelease: false
|
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
+
none: false
|
|
90
|
+
requirements:
|
|
91
|
+
- - ~>
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: 0.9.2
|
|
94
|
+
- !ruby/object:Gem::Dependency
|
|
95
|
+
name: methadone
|
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
|
97
|
+
none: false
|
|
98
|
+
requirements:
|
|
99
|
+
- - ~>
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: 1.3.1
|
|
102
|
+
type: :runtime
|
|
103
|
+
prerelease: false
|
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
+
none: false
|
|
106
|
+
requirements:
|
|
107
|
+
- - ~>
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: 1.3.1
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: rspec
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
none: false
|
|
114
|
+
requirements:
|
|
115
|
+
- - ! '>='
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
none: false
|
|
122
|
+
requirements:
|
|
123
|
+
- - ! '>='
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '0'
|
|
126
|
+
description: Make a remote tmux play well with ssh-agent
|
|
127
|
+
email:
|
|
128
|
+
- anichols@trumped.org
|
|
129
|
+
executables:
|
|
130
|
+
- sc
|
|
131
|
+
extensions: []
|
|
132
|
+
extra_rdoc_files: []
|
|
133
|
+
files:
|
|
134
|
+
- .gitignore
|
|
135
|
+
- Gemfile
|
|
136
|
+
- Gemfile.lock
|
|
137
|
+
- LICENSE.txt
|
|
138
|
+
- README.md
|
|
139
|
+
- README.rdoc
|
|
140
|
+
- Rakefile
|
|
141
|
+
- bin/sc
|
|
142
|
+
- features/sc_tmux.feature
|
|
143
|
+
- features/step_definitions/sc_tmux_steps.rb
|
|
144
|
+
- features/support/env.rb
|
|
145
|
+
- lib/sc_tmux.rb
|
|
146
|
+
- lib/sc_tmux/version.rb
|
|
147
|
+
- sc_tmux.gemspec
|
|
148
|
+
- spec/something_spec.rb
|
|
149
|
+
homepage: ''
|
|
150
|
+
licenses:
|
|
151
|
+
- MIT
|
|
152
|
+
post_install_message:
|
|
153
|
+
rdoc_options: []
|
|
154
|
+
require_paths:
|
|
155
|
+
- lib
|
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
|
+
none: false
|
|
158
|
+
requirements:
|
|
159
|
+
- - ! '>='
|
|
160
|
+
- !ruby/object:Gem::Version
|
|
161
|
+
version: '0'
|
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
|
+
none: false
|
|
164
|
+
requirements:
|
|
165
|
+
- - ! '>='
|
|
166
|
+
- !ruby/object:Gem::Version
|
|
167
|
+
version: '0'
|
|
168
|
+
requirements: []
|
|
169
|
+
rubyforge_project:
|
|
170
|
+
rubygems_version: 1.8.23
|
|
171
|
+
signing_key:
|
|
172
|
+
specification_version: 3
|
|
173
|
+
summary: Make a remote tmux play well with ssh-agent
|
|
174
|
+
test_files:
|
|
175
|
+
- features/sc_tmux.feature
|
|
176
|
+
- features/step_definitions/sc_tmux_steps.rb
|
|
177
|
+
- features/support/env.rb
|
|
178
|
+
- spec/something_spec.rb
|