mkalias 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +8 -2
- data/exe/mkalias +8 -1
- data/lib/mkalias/version.rb +1 -1
- data/lib/mkalias.rb +7 -2
- 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: 05a6270a896891df2ebb804f034a9def42a8fec9
|
4
|
+
data.tar.gz: 04d6f084313700132eeb2071e2c61e8e1167ee76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbcc6657d786caf3949845a46afedc8a5e98c8c6c198bbf00992de26b2141f32daca4c8b4b21f4a36877c4d6c498e25b6a1764057056a4b55a58765e2b3c9937
|
7
|
+
data.tar.gz: ef2b38c3aa870140ce2477e7eb9415f6e46bfdc7655ac8560d28dc847caed74991687b1c1867716f9c3f8116af5b1ba2f395a8f8d9a68185fa73aa8e0a4aa5a7
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -22,14 +22,20 @@ Or install it yourself as:
|
|
22
22
|
## Usage
|
23
23
|
|
24
24
|
run: $ mkalias [option]
|
25
|
+
|
25
26
|
option: new -> mkalias new [alias] [command]
|
27
|
+
|
26
28
|
option: list -> mkalias list
|
29
|
+
|
27
30
|
option: show -> mkalias show [alias]
|
31
|
+
|
28
32
|
option: remove -> mkalias remove [alias]
|
29
33
|
|
30
34
|
Attention: To make alias with args use #. Example:
|
31
|
-
|
32
|
-
|
35
|
+
|
36
|
+
$ mkalias new [alias] "echo #1 #2 #3"
|
37
|
+
|
38
|
+
Then you can use: $ [alias] arg1 arg2 arg3
|
33
39
|
|
34
40
|
|
35
41
|
## Development
|
data/exe/mkalias
CHANGED
@@ -24,7 +24,14 @@ def new_alias
|
|
24
24
|
|
25
25
|
alias_name = ARGV[1]
|
26
26
|
command = ARGV[2]
|
27
|
-
Mkalias.new_alias(alias_name, command)
|
27
|
+
result = Mkalias.new_alias(alias_name, command)
|
28
|
+
|
29
|
+
if result
|
30
|
+
puts " - Created Alias: #{alias_name}"
|
31
|
+
puts " - Run '$ bash --login' to use your alias"
|
32
|
+
else
|
33
|
+
puts " ERROR: O Alias [#{alias_name}] já existe"
|
34
|
+
end
|
28
35
|
end
|
29
36
|
|
30
37
|
def list_alias
|
data/lib/mkalias/version.rb
CHANGED
data/lib/mkalias.rb
CHANGED
@@ -6,6 +6,9 @@ module Mkalias
|
|
6
6
|
BASHRC_PATH = "#{File.expand_path('~')}/.bashrc"
|
7
7
|
|
8
8
|
def self.new_alias(alias_name, command, file_path=BASHRC_PATH)
|
9
|
+
alias_names = Mkalias.list_alias(file_path)
|
10
|
+
return false if alias_names.include?(alias_name)
|
11
|
+
|
9
12
|
command = command.gsub('#', '$')
|
10
13
|
|
11
14
|
function_name = "mkalias_#{alias_name}"
|
@@ -17,6 +20,8 @@ module Mkalias
|
|
17
20
|
file.puts(bash_alias)
|
18
21
|
file.puts(bash_function)
|
19
22
|
end
|
23
|
+
|
24
|
+
true
|
20
25
|
end
|
21
26
|
|
22
27
|
def self.list_alias(file_path=BASHRC_PATH)
|
@@ -34,7 +39,7 @@ module Mkalias
|
|
34
39
|
end
|
35
40
|
|
36
41
|
def self.show_alias(alias_name, file_path=BASHRC_PATH)
|
37
|
-
alias_names = Mkalias.list_alias
|
42
|
+
alias_names = Mkalias.list_alias(file_path)
|
38
43
|
return nil unless alias_names.include?(alias_name)
|
39
44
|
|
40
45
|
alias_regex = /\bmkalias_#{alias_name}[(]/
|
@@ -51,7 +56,7 @@ module Mkalias
|
|
51
56
|
end
|
52
57
|
|
53
58
|
def self.remove_alias(alias_name, file_path=BASHRC_PATH)
|
54
|
-
alias_names = Mkalias.list_alias
|
59
|
+
alias_names = Mkalias.list_alias(file_path)
|
55
60
|
return false unless alias_names.include?(alias_name)
|
56
61
|
|
57
62
|
alias_regex = /\bmkalias_#{alias_name}[(']/
|