i2cssh 1.4.4 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +66 -0
- data/VERSION +1 -1
- data/bin/i2cssh +28 -8
- data/i2cssh.gemspec +2 -2
- data/lib/i2cssh.rb +18 -6
- metadata +5 -5
data/README.markdown
CHANGED
@@ -12,6 +12,7 @@ to all sessions.
|
|
12
12
|
Usage: i2cssh [options] [(username@host [username@host] | username@cluster)]
|
13
13
|
-A, --forward-agent Enable SSH agent forwarding
|
14
14
|
-l, --login LOGIN SSH login name
|
15
|
+
-e, --environment KEY=VAL Send environment vars (comma-separated list, need to start with LC_)
|
15
16
|
-F, --fullscreen Make the window fullscreen
|
16
17
|
-C, --columns COLUMNS Number of columns (rows will be calculated)
|
17
18
|
-R, --rows ROWS Number of rows (columns will be calculated)
|
@@ -21,6 +22,7 @@ to all sessions.
|
|
21
22
|
-2, --iterm2 Use iTerm2 instead of iTerm
|
22
23
|
-f, --file FILE Cluster file (one hostname per line)
|
23
24
|
-c, --cluster CLUSTERNAME Name of the cluster specified in ~/.i2csshrc
|
25
|
+
-r, --rank Send LC_RANK with the host number as environment variable
|
24
26
|
-m, --machines a,b,c Comma-separated list of hosts
|
25
27
|
|
26
28
|
i2cssh will assume you want to connect to a cluster when only one host is given.
|
@@ -57,6 +59,12 @@ Optional parameters can be used globablly or per cluster and include:
|
|
57
59
|
broadcast: (true/false) # Enable/disable broadcast on start
|
58
60
|
login: <username> # Use this username for login
|
59
61
|
profile: <iTerm2 profile> # Use this iTerm profile
|
62
|
+
rank: (true/false) # Enable sending LC_RANK as an environment variable
|
63
|
+
|
64
|
+
environment: # Send the following enviroment variables
|
65
|
+
- LC_FOO: foo
|
66
|
+
- LC_BAR: bar
|
67
|
+
|
60
68
|
iterm2: true # Use iTerm2.app instead of iTerm.app (only available globally)
|
61
69
|
|
62
70
|
The following precedence is used:
|
@@ -65,6 +73,64 @@ global options from config < cluster options from config < command line flags
|
|
65
73
|
|
66
74
|
Make sure the config file is valid YAML (e.g. use spaces instead of tabs)
|
67
75
|
|
76
|
+
## Options
|
77
|
+
|
78
|
+
### -A, --forward-agent
|
79
|
+
|
80
|
+
Enable SSH agent forwarding
|
81
|
+
|
82
|
+
### -l, --login LOGIN
|
83
|
+
|
84
|
+
This option will override all logins passed in to i2cssh. This goes for global config, cluster config or username@host passed on the command line
|
85
|
+
|
86
|
+
### -e, --environment KEY=VAL
|
87
|
+
|
88
|
+
Allows for passing environment varables to the SSH session. This can be a comma-separated list: `-e LC_FOO=foo,LC_BAR=bar`
|
89
|
+
|
90
|
+
### -F, --fullscreen
|
91
|
+
|
92
|
+
Enable fullscreen on startup
|
93
|
+
|
94
|
+
### -C, --columns COLUMNS
|
95
|
+
|
96
|
+
Set the amount of columns. Can't be used in conjunction with -R
|
97
|
+
|
98
|
+
### -R, --rows ROWS
|
99
|
+
|
100
|
+
Set the amount of columns. Can't be used in conjunction with -C
|
101
|
+
|
102
|
+
### -b, --broadcast
|
103
|
+
|
104
|
+
Enable broadcast on startup. i2cssh will send cmd-shift-i to the window and press the OK button.
|
105
|
+
|
106
|
+
### -nb, --nobroadcast
|
107
|
+
|
108
|
+
Disable broadcast. This setting can be used to disable any broadcast that was set in the config.
|
109
|
+
|
110
|
+
### -p, --profile PROFILE
|
111
|
+
|
112
|
+
Use a specific iTerm profile
|
113
|
+
|
114
|
+
### -2, --iterm2
|
115
|
+
|
116
|
+
Use iTerm2.app instead of iTerm.app
|
117
|
+
|
118
|
+
### -f, --file
|
119
|
+
|
120
|
+
Will read nodes from a file. These will be added to any hosts specified on the command line or in the config
|
121
|
+
|
122
|
+
### -c, --cluster
|
123
|
+
|
124
|
+
Connect to a cluster that is specified in the config
|
125
|
+
|
126
|
+
### -r, --rank
|
127
|
+
|
128
|
+
Send a LC_RANK environment variable different for each host
|
129
|
+
|
130
|
+
### -m, --machines a,b,c
|
131
|
+
|
132
|
+
Connect to the machines a, b and c
|
133
|
+
|
68
134
|
## Known issues
|
69
135
|
|
70
136
|
- i2cssh uses rb-appscript and that only seems to work on ruby 1.8.7 and breaks on 1.9.x
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.5.0
|
data/bin/i2cssh
CHANGED
@@ -3,10 +3,11 @@ require 'rubygems'
|
|
3
3
|
require 'optparse'
|
4
4
|
require 'i2cssh'
|
5
5
|
require 'yaml'
|
6
|
+
require 'pp'
|
6
7
|
|
7
8
|
@config_file = File.expand_path "~/.i2csshrc"
|
8
9
|
|
9
|
-
@i2_options, ssh_options, @servers, @clusters = {}, [], [], {}
|
10
|
+
@i2_options, ssh_options, @servers, @clusters, @ssh_environment = {}, [], [], {}, {}
|
10
11
|
|
11
12
|
def get_hosts(c)
|
12
13
|
if c =~ /(.+)@(.+)/ then
|
@@ -19,15 +20,18 @@ def get_hosts(c)
|
|
19
20
|
if cluster
|
20
21
|
cluster_hosts = cluster["hosts"]
|
21
22
|
|
22
|
-
@i2_options[:login_override] = cluster["login"]
|
23
|
+
@i2_options[:login_override] = !cluster["login"].nil? ? cluster["login"] : @i2_options[:login_override]
|
23
24
|
@i2_options[:login_override] = login_from_cli if login_from_cli
|
24
|
-
@i2_options[:broadcast] = cluster["broadcast"]
|
25
|
-
@i2_options[:profile] = cluster["profile"]
|
25
|
+
@i2_options[:broadcast] = !cluster["broadcast"].nil? ? cluster["broadcast"] : @i2_options[:broadcast]
|
26
|
+
@i2_options[:profile] = !cluster["profile"].nil? ? cluster["profile"] : @i2_options[:profile]
|
27
|
+
@i2_options[:rank] = !cluster["rank"].nil? ? cluster["rank"] : @i2_options[:rank]
|
26
28
|
|
27
29
|
if @i2_options[:login_override] then
|
28
30
|
cluster_hosts = cluster_hosts.map{|h| "#{@i2_options[:login_override]}@#{h}"}
|
29
31
|
end
|
30
32
|
|
33
|
+
@ssh_environment.merge!(cluster["environment"].inject({}){|m, v| m.merge(v)}) if cluster["environment"]
|
34
|
+
|
31
35
|
@servers += cluster_hosts
|
32
36
|
else
|
33
37
|
puts "ERROR: unknown cluster #{c}. Check your #{@config_file}"
|
@@ -47,6 +51,9 @@ if File.exists?(@config_file)
|
|
47
51
|
@i2_options[:login_override] = config_hash["login"]
|
48
52
|
@i2_options[:broadcast] = config_hash["broadcast"]
|
49
53
|
@i2_options[:profile] = config_hash["profile"]
|
54
|
+
@i2_options[:rank] = config_hash["rank"]
|
55
|
+
|
56
|
+
@ssh_environment.merge!(config_hash["environment"].inject({}){|m, v| m.merge(v)}) if config_hash["environment"]
|
50
57
|
|
51
58
|
else
|
52
59
|
# Convert version 1 format to version 2
|
@@ -87,6 +94,14 @@ optparse = OptionParser.new do |opts|
|
|
87
94
|
@i2_options[:login_override] = u
|
88
95
|
|
89
96
|
end
|
97
|
+
opts.on '-e', '--environment KEY=VAL',
|
98
|
+
'Send environment vars (comma-separated list, need to start with LC_)' do |e|
|
99
|
+
@ssh_environment = e.split(",").inject({}) {|m, x| key, val = x.split("="); m[key] = val; m}
|
100
|
+
end
|
101
|
+
opts.on '-r', '--rank',
|
102
|
+
'Send LC_RANK with the host number as environment variable' do
|
103
|
+
@i2_options[:rank] = true
|
104
|
+
end
|
90
105
|
|
91
106
|
# iTerm2 options
|
92
107
|
opts.on '-F', '--fullscreen',
|
@@ -95,14 +110,20 @@ optparse = OptionParser.new do |opts|
|
|
95
110
|
end
|
96
111
|
opts.on '-C', '--columns COLUMNS', Integer,
|
97
112
|
'Number of columns (rows will be calculated)' do |c|
|
98
|
-
@i2_options[:
|
113
|
+
if @i2_options[:rows]
|
114
|
+
puts "ERROR: -C and -R can't be used at the same time"
|
115
|
+
puts optparse.help
|
116
|
+
exit 1
|
117
|
+
else
|
118
|
+
@i2_options[:columns] = c
|
119
|
+
end
|
99
120
|
end
|
100
121
|
opts.on '-R', '--rows ROWS', Integer,
|
101
122
|
'Number of rows (columns will be calculated)' do |r|
|
102
123
|
if @i2_options[:columns]
|
103
124
|
puts "ERROR: -C and -R can't be used at the same time"
|
104
125
|
puts optparse.help
|
105
|
-
exit
|
126
|
+
exit 1
|
106
127
|
else
|
107
128
|
@i2_options[:rows] = r
|
108
129
|
end
|
@@ -118,7 +139,6 @@ optparse = OptionParser.new do |opts|
|
|
118
139
|
opts.on '-p', '--profile PROFILE',
|
119
140
|
'Name of the iTerm2 profile (default: Default)' do |p|
|
120
141
|
@i2_options[:profile] = p
|
121
|
-
puts p
|
122
142
|
end
|
123
143
|
opts.on "-2", '--iterm2',
|
124
144
|
'Use iTerm2 instead of iTerm' do
|
@@ -145,4 +165,4 @@ if @servers.empty?
|
|
145
165
|
exit
|
146
166
|
end
|
147
167
|
|
148
|
-
I2Cssh.new @servers, ssh_options, @i2_options
|
168
|
+
I2Cssh.new @servers, ssh_options, @i2_options, @ssh_environment
|
data/i2cssh.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "i2cssh"
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.5.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Wouter de Bie"]
|
12
|
-
s.date = "2012-03-
|
12
|
+
s.date = "2012-03-23"
|
13
13
|
s.description = "csshX like cluster ssh using iTerm2 panes"
|
14
14
|
s.email = "wouter@evenflow.se"
|
15
15
|
s.executables = ["i2cssh"]
|
data/lib/i2cssh.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'appscript'
|
2
2
|
|
3
3
|
class I2Cssh
|
4
|
-
def initialize servers, ssh_options, i2_options
|
5
|
-
@ssh_prefix
|
6
|
-
@ssh_options
|
7
|
-
@i2_options
|
8
|
-
@servers
|
4
|
+
def initialize servers, ssh_options, i2_options, ssh_environment
|
5
|
+
@ssh_prefix = "ssh " + ssh_options.join(' ')
|
6
|
+
@ssh_options = ssh_options
|
7
|
+
@i2_options = i2_options
|
8
|
+
@servers = servers
|
9
|
+
@ssh_environment = ssh_environment
|
9
10
|
|
10
11
|
app_name = (i2_options[:iterm2]) ? 'iTerm2' : 'iTerm'
|
11
12
|
|
@@ -77,7 +78,18 @@ class I2Cssh
|
|
77
78
|
1.upto(@rows*@columns) do |i|
|
78
79
|
server = @servers[i-1]
|
79
80
|
if server then
|
80
|
-
|
81
|
+
ssh_env = ""
|
82
|
+
|
83
|
+
if @i2_options[:rank] then
|
84
|
+
@ssh_environment['LC_RANK'] = i-1
|
85
|
+
end
|
86
|
+
|
87
|
+
if !@ssh_environment.empty? then
|
88
|
+
send_env = "-o SendEnv=#{@ssh_environment.keys.join(",")}"
|
89
|
+
@term.sessions[i].write :text => "#{@ssh_environment.map{|k,v| "export #{k}=#{v}"}.join('; ')}"
|
90
|
+
end
|
91
|
+
|
92
|
+
@term.sessions[i].write :text => "unset HISTFILE && echo -e \"\\033]50;SetProfile=#{@profile}\\a\" && #{@ssh_prefix} #{send_env} #{server}"
|
81
93
|
else
|
82
94
|
|
83
95
|
@term.sessions[i].write :text => "unset HISTFILE && echo -e \"\\033]50;SetProfile=#{@profile}\\a\""
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i2cssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 1.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Wouter de Bie
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-03-
|
18
|
+
date: 2012-03-23 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
prerelease: false
|