agen 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -17
- data/lib/agen/builder.rb +11 -3
- data/lib/agen/runner.rb +2 -2
- data/lib/agen/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcbe6011253c346bb0abe4d9147146610cbc9fc98f7769f31b960ba20304af17
|
4
|
+
data.tar.gz: 5e8035ec1fb0aec32b660395ea24d6d5a8a88aa9e8cc88d0122115d6a2358150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ca5c06be491092c201c8dcbce7623f0a887d4fbd52e36ab9afc27281ced79fbc97ecb878fc016f4c958893e82bd6718cd08f978c2619fc7a8f59bee7e84358a
|
7
|
+
data.tar.gz: 6e62b98c8745005dd1c1632abdc44adef8b55c9e47cfab0318652248b6e5df125109f378b53ca549c8521b6fa07bb70554397b09bcdb63e6bfdb24342f20e30b
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
## [Released]
|
2
2
|
|
3
|
-
## [0.1.
|
4
|
-
- Avoids most alias naming conflicts with commands that already exist (e.g. `ls`)
|
5
|
-
|
6
|
-
## [0.1.3] - 2021-04-24
|
3
|
+
## [0.1.5] - 2021-04-24
|
7
4
|
|
8
5
|
- Initial release that anyone should reasonably use.
|
9
6
|
- Support for .zshrc/.zsh_history.
|
10
7
|
- Automatically writes top 5 aliases for commands 6 characters or longer.
|
8
|
+
- Avoids most alias naming conflicts with commands that already exist (e.g. `ls`).
|
9
|
+
- Avoids duplicating aliases that have already been written.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -23,24 +23,17 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Jonath
|
|
23
23
|
|
24
24
|
## Roadmap
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
- [x] It should not create aliases for very short commands.
|
33
|
-
~~2. CLI should not duplicate aliases or commands that already exist on the system.~~
|
34
|
-
3. CLI will let you see proposed aliases and accept/decline them interactively. Maybe auto should be the default?
|
35
|
-
OR, in "auto mode", commands will be added automatically (as in 1).
|
36
|
-
4. CLI should have helpful output for `-h/--help`.
|
37
|
-
5. CLI will let you specify number of aliases you want to create.
|
38
|
-
6. CLI will support any (or most common) shells, and will find history and rc
|
26
|
+
* CLI will let you specify number of aliases you want to create.
|
27
|
+
* CLI will let you see proposed aliases and accept/decline them interactively.
|
28
|
+
OR, in "auto mode", commands will be added automatically (as in 1). Auto
|
29
|
+
should be default?
|
30
|
+
* CLI should have helpful output for `-h/--help`.
|
31
|
+
* CLI will support any (or most common) shells, and will find history and rc
|
39
32
|
file dynamically.
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
* CLI will let you specific which history file to read form, and which file to output aliases to.
|
34
|
+
* CLI will let you interactively modify proposed aliases.
|
35
|
+
* CLI will let you "ignore" commands you don't want to alias, forever.
|
36
|
+
* CLI will let you specify "meta" vs "full" commands.
|
44
37
|
- Full command would be `git checkout branch-name`, meta command would be
|
45
38
|
`git checkout`.
|
46
39
|
|
data/lib/agen/builder.rb
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
module Agen
|
4
4
|
class Builder
|
5
|
-
def initialize(commands)
|
5
|
+
def initialize(commands, rcfile = Runner::DEFAULT_RCFILE)
|
6
6
|
@commands = commands
|
7
|
+
@rcfile = rcfile
|
7
8
|
end
|
8
9
|
|
9
10
|
def aliases
|
@@ -17,8 +18,15 @@ module Agen
|
|
17
18
|
aliaz += aliaz[-1]
|
18
19
|
end
|
19
20
|
|
20
|
-
"alias #{aliaz}=\"#{cmd}\""
|
21
|
-
|
21
|
+
candidate = "alias #{aliaz}=\"#{cmd}\""
|
22
|
+
candidate if alias_does_not_exist?(candidate)
|
23
|
+
end.compact
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def alias_does_not_exist?(aliaz)
|
29
|
+
File.readlines(@rcfile).none? { |line| line.include?(aliaz) }
|
22
30
|
end
|
23
31
|
|
24
32
|
# Shoutout to Stack Overflow: https://stackoverflow.com/a/5471032
|
data/lib/agen/runner.rb
CHANGED
@@ -14,10 +14,10 @@ module Agen
|
|
14
14
|
|
15
15
|
def run
|
16
16
|
commands = Finder.new(histfile).commands
|
17
|
-
aliases = Builder.new(commands).aliases
|
17
|
+
aliases = Builder.new(commands, rcfile).aliases
|
18
18
|
|
19
19
|
File.open(rcfile, "a") do |file|
|
20
|
-
puts "Writing aliases to #{rcfile}:"
|
20
|
+
puts "Writing new aliases to #{rcfile}:"
|
21
21
|
aliases.each do |al|
|
22
22
|
puts al
|
23
23
|
file.puts(al)
|
data/lib/agen/version.rb
CHANGED