ssh-config 0.1.3 → 0.1.4
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.
- checksums.yaml +5 -5
- data/CHANGES +1 -1
- data/bin/ssh-config +15 -2
- data/lib/config_file.rb +11 -5
- data/lib/config_section.rb +2 -1
- metadata +49 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d36111053e6e4166b288b803b78f83d7fa71667e23ad9d8a7bb836e3eddbe74f
|
|
4
|
+
data.tar.gz: 3d7dcc8a6d83029841ccd5f2c6b51bb008e20948d02dfca0643fd07a3ff87e17
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e32609207782fd80628f50cc599d92acb6aec7e51f7ce272eb14c5569c28373d5c2cf5cc52f623749c122b8954894db7d1a0979ba23295f0ef95477aa122a59
|
|
7
|
+
data.tar.gz: 90d3c936c2cfec3e6b80fcde3387afd35fc67867752f354df1248f8b5d9cae3c66cf14a7c518ec68a7f13d58052d4e4e6aa9f39b4e03816fc8c13e20f2e5cb31
|
data/CHANGES
CHANGED
data/bin/ssh-config
CHANGED
|
@@ -45,13 +45,26 @@ HELP
|
|
|
45
45
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
+
def colorize output
|
|
49
|
+
# Colorize hostname and aliases
|
|
50
|
+
output = output.gsub(/Host\s+([a-zA-Z0-9 ]*)/, "\033[33mHost \033[31m"+'\1'+"\033[0m")
|
|
51
|
+
# Colorize comments
|
|
52
|
+
output = output.gsub("#", "\033[30m#").gsub("\n", "\033[0m\n")
|
|
53
|
+
# Colorize parameters
|
|
54
|
+
output.gsub(/^(\s*[a-zA-Z0-9]*\s*\b)/, "\033[37m"+'\1'+"\033[0m")
|
|
55
|
+
end
|
|
56
|
+
|
|
48
57
|
case command
|
|
58
|
+
when '-?'
|
|
59
|
+
puts usage
|
|
60
|
+
when '-h'
|
|
61
|
+
puts usage
|
|
49
62
|
when 'help'
|
|
50
63
|
puts usage
|
|
51
64
|
when 'list'
|
|
52
65
|
puts config.list
|
|
53
66
|
when 'show'
|
|
54
|
-
puts config.show(*argv)
|
|
67
|
+
puts colorize config.show(*argv)
|
|
55
68
|
when 'search'
|
|
56
69
|
search = argv.shift
|
|
57
70
|
result = config.search(search).gsub(search, "\033[43m#{search}\033[0m")
|
|
@@ -65,7 +78,7 @@ when 'set'
|
|
|
65
78
|
when 'rm', 'del', 'delete'
|
|
66
79
|
config.rm! argv.shift
|
|
67
80
|
when 'dump'
|
|
68
|
-
puts config.dump
|
|
81
|
+
puts colorize config.dump
|
|
69
82
|
when 'alias'
|
|
70
83
|
config.alias!(*argv)
|
|
71
84
|
when 'unalias'
|
data/lib/config_file.rb
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
1
3
|
class ConfigFile
|
|
2
|
-
def initialize
|
|
3
|
-
@
|
|
4
|
+
def initialize(file_location = '~/.ssh/config', make_backups = true)
|
|
5
|
+
@config_file_location = file_location
|
|
6
|
+
@make_backups = make_backups
|
|
4
7
|
@header_lines = []
|
|
5
8
|
@sections = []
|
|
6
9
|
@sections_by_name = {}
|
|
@@ -16,7 +19,9 @@ class ConfigFile
|
|
|
16
19
|
|
|
17
20
|
def read_config
|
|
18
21
|
current_section = nil
|
|
19
|
-
|
|
22
|
+
filename = File.expand_path(@config_file_location)
|
|
23
|
+
return unless File.exist?(filename)
|
|
24
|
+
IO.readlines(filename).each_with_index do |line, i|
|
|
20
25
|
line.rstrip!
|
|
21
26
|
if line =~ /\bHost\s+(.+)/
|
|
22
27
|
current_section = add_section($1)
|
|
@@ -149,13 +154,14 @@ class ConfigFile
|
|
|
149
154
|
end
|
|
150
155
|
|
|
151
156
|
def save
|
|
152
|
-
File.open(File.expand_path(
|
|
157
|
+
File.open(File.expand_path(@config_file_location), "w") do |file|
|
|
153
158
|
file.puts dump
|
|
154
159
|
end
|
|
155
160
|
end
|
|
156
161
|
|
|
157
162
|
def backup
|
|
158
|
-
|
|
163
|
+
filename = File.expand_path(@config_file_location)
|
|
164
|
+
FileUtils.copy(filename, filename + "~") if File.exist?(filename)
|
|
159
165
|
end
|
|
160
166
|
|
|
161
167
|
private
|
data/lib/config_section.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ssh-config
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Brady
|
|
@@ -9,17 +9,56 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
date: 2011-02-09 00:00:00.000000000 Z
|
|
12
|
-
dependencies:
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rspec-core
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '3.7'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '3.7'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rspec-expectations
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '3.7'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '3.7'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: simplecov
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - '='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.20.0
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - '='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 0.20.0
|
|
13
55
|
description: Ssh-Config, a tool that lets you quickly add, update, remove, and copy
|
|
14
56
|
ssh config file entries.
|
|
15
57
|
email: github@shinybit.com
|
|
16
58
|
executables:
|
|
17
59
|
- ssh-config
|
|
18
60
|
extensions: []
|
|
19
|
-
extra_rdoc_files:
|
|
20
|
-
- README.rdoc
|
|
21
|
-
- MIT-LICENSE
|
|
22
|
-
- CHANGES
|
|
61
|
+
extra_rdoc_files: []
|
|
23
62
|
files:
|
|
24
63
|
- CHANGES
|
|
25
64
|
- MIT-LICENSE
|
|
@@ -32,28 +71,21 @@ homepage: http://github.com/dbrady/ssh-config/
|
|
|
32
71
|
licenses: []
|
|
33
72
|
metadata: {}
|
|
34
73
|
post_install_message:
|
|
35
|
-
rdoc_options:
|
|
36
|
-
- --line-numbers
|
|
37
|
-
- --inline-source
|
|
38
|
-
- --main
|
|
39
|
-
- README.rdoc
|
|
40
|
-
- --title
|
|
41
|
-
- Ssh-Config - A Tool for ssh config files
|
|
74
|
+
rdoc_options: []
|
|
42
75
|
require_paths:
|
|
43
76
|
- lib
|
|
44
77
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
78
|
requirements:
|
|
46
|
-
- -
|
|
79
|
+
- - ">="
|
|
47
80
|
- !ruby/object:Gem::Version
|
|
48
81
|
version: '0'
|
|
49
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
83
|
requirements:
|
|
51
|
-
- -
|
|
84
|
+
- - ">="
|
|
52
85
|
- !ruby/object:Gem::Version
|
|
53
86
|
version: '0'
|
|
54
87
|
requirements: []
|
|
55
|
-
|
|
56
|
-
rubygems_version: 2.0.3
|
|
88
|
+
rubygems_version: 3.0.8
|
|
57
89
|
signing_key:
|
|
58
90
|
specification_version: 4
|
|
59
91
|
summary: Ssh-Config - tool for managing your .ssh/config file
|