agen 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 +4 -4
- data/.github/workflows/main.yml +1 -1
- data/CHANGELOG.md +8 -3
- data/Gemfile.lock +1 -1
- data/README.md +30 -42
- data/lib/agen/builder.rb +21 -0
- data/lib/agen/finder.rb +1 -1
- 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: ac1f9e3386a6c2aa6a792d31040e869cd0cc2243335b0406d8636003cdd91737
|
4
|
+
data.tar.gz: c8465c062ca6dba68556e80a22ba7600688f7a60e237c1e2f01352c6fffd7a1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ce071d533b7af081c55e7cd1f91c8326a9145c4731c2e891e84c1b93544207df5159824646a78623707afd1e0bfb5d6062bdeab65bf94cd4afd1a8da0d58d7b
|
7
|
+
data.tar.gz: 66138b4626cb5c8b257e5325904a9efd8d9ee8e3623bc59ec78e2b58e46e654c4b3ff90e1e702bb5b03c57c5218f9bb844330b4bf659a0184e0f1d54157b0f0a
|
data/.github/workflows/main.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
-
## [
|
1
|
+
## [Released]
|
2
2
|
|
3
|
-
## [0.1.
|
3
|
+
## [0.1.4] - 2021-04-24
|
4
|
+
- Avoids most alias naming conflicts with commands that already exist (e.g. `ls`)
|
4
5
|
|
5
|
-
-
|
6
|
+
## [0.1.3] - 2021-04-24
|
7
|
+
|
8
|
+
- Initial release that anyone should reasonably use.
|
9
|
+
- Support for .zshrc/.zsh_history.
|
10
|
+
- Automatically writes top 5 aliases for commands 6 characters or longer.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,50 +1,15 @@
|
|
1
1
|
# Agen
|
2
2
|
|
3
|
-
|
3
|
+
[](https://github.com/JonathanWThom/agen/actions/workflows/main.yml)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
1. CLI will read 5 most common full commands from .zsh_history file, and create
|
8
|
-
an alias for them in the .zshrc file.
|
9
|
-
- It should not create aliases out of old aliases.
|
10
|
-
- It should handle a very short or shell history without many different
|
11
|
-
commands.
|
12
|
-
- It should output progress for very long/slow shell histories.
|
13
|
-
- It should not create the same alias for two different commands in the same
|
14
|
-
session.
|
15
|
-
- It should not create an alias that is longer than the original command.
|
16
|
-
1. CLI will let you see proposed aliases and accept/decline them interactively.
|
17
|
-
OR, in "auto mode", commands will be added automatically (as in 1).
|
18
|
-
1. CLI should have helpful output for `-h/--help`.
|
19
|
-
1. CLI will let you specify number of aliases you want to create.
|
20
|
-
1. CLI will support any (or most common) shells, and will find history and rc
|
21
|
-
file dynamically.
|
22
|
-
1. CLI will let you specific which history file to read form, and which file to output aliases to.
|
23
|
-
1. CLI will let you interactively modify proposed aliases.
|
24
|
-
1. CLI will let you "ignore" commands you don't want to alias, forever.
|
25
|
-
1. CLI will let you specify "meta" vs "full" commands.
|
26
|
-
- Full command would be `git checkout branch-name`, meta command would be
|
27
|
-
`git checkout`.
|
28
|
-
|
29
|
-
## Installation
|
30
|
-
|
31
|
-
Add this line to your application's Gemfile:
|
32
|
-
|
33
|
-
```ruby
|
34
|
-
gem 'agen'
|
35
|
-
```
|
36
|
-
|
37
|
-
And then execute:
|
5
|
+
Generate shell aliases based on your most commonly entered commands.
|
38
6
|
|
39
|
-
|
7
|
+
## Installation & Usage
|
40
8
|
|
41
|
-
|
9
|
+
Install with `gem install agen` and then run `agen` to build your aliases.
|
42
10
|
|
43
|
-
|
44
|
-
|
45
|
-
## Usage
|
46
|
-
|
47
|
-
TODO: Write usage instructions here
|
11
|
+
Right now, this will only work with `zsh`, but support for other shells is on
|
12
|
+
the very lengthy todo list.
|
48
13
|
|
49
14
|
## Development
|
50
15
|
|
@@ -54,7 +19,30 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
54
19
|
|
55
20
|
## Contributing
|
56
21
|
|
57
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
22
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/JonathanWThom/agen.
|
23
|
+
|
24
|
+
## Roadmap
|
25
|
+
|
26
|
+
~~1. CLI will read 5 most common full commands from .zsh_history file, and create
|
27
|
+
an alias for them in the .zshrc file.~~
|
28
|
+
- [x] It should handle a very short or shell history without many different
|
29
|
+
commands.
|
30
|
+
- [x] It should not create the same alias for two different commands in the same
|
31
|
+
session.
|
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
|
39
|
+
file dynamically.
|
40
|
+
7. CLI will let you specific which history file to read form, and which file to output aliases to.
|
41
|
+
8. CLI will let you interactively modify proposed aliases.
|
42
|
+
9. CLI will let you "ignore" commands you don't want to alias, forever.
|
43
|
+
10. CLI will let you specify "meta" vs "full" commands.
|
44
|
+
- Full command would be `git checkout branch-name`, meta command would be
|
45
|
+
`git checkout`.
|
58
46
|
|
59
47
|
## License
|
60
48
|
|
data/lib/agen/builder.rb
CHANGED
@@ -9,8 +9,29 @@ module Agen
|
|
9
9
|
def aliases
|
10
10
|
@commands.map do |cmd|
|
11
11
|
aliaz = cmd.scan(/\b\w/).join
|
12
|
+
|
13
|
+
# Is is possibly we could overwrite a command here still? Sure.
|
14
|
+
# I will live with it for now.
|
15
|
+
if command_already_exists?(aliaz)
|
16
|
+
# We could improve to look more like the original command, but again, works for now.
|
17
|
+
aliaz += aliaz[-1]
|
18
|
+
end
|
19
|
+
|
12
20
|
"alias #{aliaz}=\"#{cmd}\""
|
13
21
|
end
|
14
22
|
end
|
23
|
+
|
24
|
+
# Shoutout to Stack Overflow: https://stackoverflow.com/a/5471032
|
25
|
+
def command_already_exists?(cmd)
|
26
|
+
exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
|
27
|
+
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
|
28
|
+
exts.each do |ext|
|
29
|
+
exe = File.join(path, "#{cmd}#{ext}")
|
30
|
+
return true if File.executable?(exe) && !File.directory?(exe)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
false
|
35
|
+
end
|
15
36
|
end
|
16
37
|
end
|
data/lib/agen/finder.rb
CHANGED
data/lib/agen/version.rb
CHANGED