mkalias 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -10
- data/bin/mkalias +17 -15
- data/lib/mkalias/version.rb +1 -1
- data/lib/mkalias.rb +9 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5f0ed02cffd4fd402e3fea1016a1db825997e93
|
4
|
+
data.tar.gz: ce009d8d94ea833636cb5d924af3ce5a106c875f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee5f8c14eaf0c779e834b4e8fead6f83ef31393a3691faa347a6f06474ab03bdb19d2d205dda3b3265633bfaa0c15c877f6ec7a5d5976134c484877569cd434c
|
7
|
+
data.tar.gz: 9c24bde9def58e83db15a43a8f4671c58bfaf0e11a408f10f73594073c92425966e1d34b3723b75e2f7523b9b686943b9db3d007b71aaebf6307ef85cd35a3d9
|
data/README.md
CHANGED
@@ -23,20 +23,22 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
run: $ mkalias [option]
|
25
25
|
|
26
|
-
|
27
|
-
- Create a new alias to run the commands
|
26
|
+
options:
|
28
27
|
|
29
|
-
|
30
|
-
|
28
|
+
new $ mkalias new [alias] [command 1] [command 2] ... [command n]
|
29
|
+
- Create a new alias to run the commands
|
31
30
|
|
32
|
-
|
33
|
-
|
31
|
+
list $ mkalias list
|
32
|
+
- List all alias
|
34
33
|
|
35
|
-
|
36
|
-
|
34
|
+
show $ mkalias show
|
35
|
+
- Show commands of all alias
|
37
36
|
|
38
|
-
|
39
|
-
|
37
|
+
$ mkalias show [alias 1] [alias 2] ... [alias n]
|
38
|
+
- Show commands of the specified alias
|
39
|
+
|
40
|
+
remove $ mkalias remove [alias 1] [alias 2] ... [alias n]
|
41
|
+
- Remove the specified alias
|
40
42
|
|
41
43
|
Attention: To make alias with args use #. Example:
|
42
44
|
$ mkalias new [alias] "echo #1 #2 #3"
|
data/bin/mkalias
CHANGED
@@ -8,25 +8,27 @@ VALID_OPTIONS = ['new', 'list', 'show', 'remove']
|
|
8
8
|
def usage
|
9
9
|
puts "Usage: mkalias [option]"
|
10
10
|
puts ""
|
11
|
-
|
11
|
+
puts "options:"
|
12
|
+
puts ""
|
13
|
+
puts " new \t\t $ mkalias new [alias] [command 1] [command 2] ..." \
|
12
14
|
" [command n]"
|
13
|
-
puts "- Create a new alias to run the commands"
|
15
|
+
puts "\t\t - Create a new alias to run the commands"
|
14
16
|
puts ""
|
15
|
-
puts "
|
16
|
-
puts "- List all alias"
|
17
|
+
puts " list \t\t $ mkalias list"
|
18
|
+
puts "\t\t - List all alias"
|
17
19
|
puts ""
|
18
|
-
puts "
|
19
|
-
puts "- Show commands of all alias"
|
20
|
+
puts " show \t\t $ mkalias show"
|
21
|
+
puts "\t\t - Show commands of all alias"
|
20
22
|
puts ""
|
21
|
-
puts "
|
22
|
-
puts "- Show commands of the specified alias"
|
23
|
+
puts "\t\t $ mkalias show [alias 1] [alias 2] ... [alias n]"
|
24
|
+
puts "\t\t - Show commands of the specified alias"
|
23
25
|
puts ""
|
24
|
-
puts "
|
25
|
-
puts "- Remove the specified alias"
|
26
|
+
puts " remove \t $ mkalias remove [alias 1] [alias 2] ... [alias n]"
|
27
|
+
puts "\t\t - Remove the specified alias"
|
26
28
|
puts ""
|
27
29
|
puts "Attention: To make alias with args use #. Example:"
|
28
|
-
puts "
|
29
|
-
puts "
|
30
|
+
puts " $ mkalias new [alias] \"echo #1 #2 #3\""
|
31
|
+
puts " - Then you can use: $ [alias] arg1 arg2 arg3"
|
30
32
|
abort
|
31
33
|
end
|
32
34
|
|
@@ -72,11 +74,11 @@ def show_alias
|
|
72
74
|
end
|
73
75
|
|
74
76
|
unless commands.empty?
|
75
|
-
commands.each do |alias_name,
|
77
|
+
commands.each do |alias_name, alias_commands|
|
76
78
|
puts "-> #{alias_name}"
|
77
79
|
|
78
|
-
|
79
|
-
puts " $ #{
|
80
|
+
alias_commands.each do |alias_command|
|
81
|
+
puts " $ #{alias_command}"
|
80
82
|
end
|
81
83
|
puts ""
|
82
84
|
end
|
data/lib/mkalias/version.rb
CHANGED
data/lib/mkalias.rb
CHANGED
@@ -42,14 +42,14 @@ module Mkalias
|
|
42
42
|
def self.show_alias(alias_names, file_path=BASHRC_PATH)
|
43
43
|
alias_names = [alias_names] unless alias_names.kind_of?(Array)
|
44
44
|
|
45
|
-
|
45
|
+
alias_commands = {}
|
46
46
|
alias_names.each do |alias_name|
|
47
|
-
|
47
|
+
alias_commands[alias_name] = Mkalias.get_alias_command(alias_name,
|
48
48
|
file_path)
|
49
49
|
end
|
50
50
|
|
51
|
-
|
52
|
-
return
|
51
|
+
alias_commands.select!{ |key, value| !value.nil? }
|
52
|
+
return alias_commands
|
53
53
|
end
|
54
54
|
|
55
55
|
def self.remove_alias(alias_names, file_path=BASHRC_PATH)
|
@@ -66,17 +66,17 @@ module Mkalias
|
|
66
66
|
|
67
67
|
private
|
68
68
|
|
69
|
-
def self.
|
69
|
+
def self.get_alias_command(alias_name, file_path=BASHRC_PATH)
|
70
70
|
alias_names = Mkalias.list_alias(file_path)
|
71
71
|
return nil unless alias_names.include?(alias_name)
|
72
72
|
|
73
73
|
alias_regex = /\bmkalias_#{alias_name}[(]/
|
74
|
-
|
74
|
+
command_regex = /[{](.*)[;]/
|
75
75
|
|
76
|
-
|
76
|
+
alias_commands = File.foreach(file_path).grep(alias_regex)
|
77
77
|
|
78
|
-
|
79
|
-
result =
|
78
|
+
alias_commands.each do |command|
|
79
|
+
result = command.match(command_regex)
|
80
80
|
return result.captures.first.split(';').each{ |c| c.strip! } if result
|
81
81
|
end
|
82
82
|
|