agen 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df67e0e93c7d387a143caea30f6227dcbe30b3adcb6aab2ef1c820a4acd1dbba
4
- data.tar.gz: dc330d76655aefdf9f0ceaafa5d421426e4883d422c5cfe48347609e3734acdc
3
+ metadata.gz: ac1f9e3386a6c2aa6a792d31040e869cd0cc2243335b0406d8636003cdd91737
4
+ data.tar.gz: c8465c062ca6dba68556e80a22ba7600688f7a60e237c1e2f01352c6fffd7a1e
5
5
  SHA512:
6
- metadata.gz: 1739ef52ab785d37134f7f91bbcc3875997086fe53f4e142afe35770e5fb28075a24dc9727eee7b986ceecc36f6f206cd84690cee5f10065eb44817de77db9c5
7
- data.tar.gz: c05fab9189e7300f4915a293ee8b55d5a6a1e41a91003e786d46ad76bfc7f2c31ca1b2933524f45d0e1d537bdec3bd70604d863372eaec95a290e4995af5cba7
6
+ metadata.gz: 2ce071d533b7af081c55e7cd1f91c8326a9145c4731c2e891e84c1b93544207df5159824646a78623707afd1e0bfb5d6062bdeab65bf94cd4afd1a8da0d58d7b
7
+ data.tar.gz: 66138b4626cb5c8b257e5325904a9efd8d9ee8e3623bc59ec78e2b58e46e654c4b3ff90e1e702bb5b03c57c5218f9bb844330b4bf659a0184e0f1d54157b0f0a
@@ -1,4 +1,4 @@
1
- name: Ruby
1
+ name: Build
2
2
 
3
3
  on: [push,pull_request]
4
4
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
- ## [Unreleased]
1
+ ## [Released]
2
2
 
3
- ## [0.1.0] - 2021-04-24
3
+ ## [0.1.4] - 2021-04-24
4
+ - Avoids most alias naming conflicts with commands that already exist (e.g. `ls`)
4
5
 
5
- - Initial release
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- agen (0.1.3)
4
+ agen (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,50 +1,15 @@
1
1
  # Agen
2
2
 
3
- Generate shell aliases based on commonly entered commands.
3
+ [![Build](https://github.com/JonathanWThom/agen/actions/workflows/main.yml/badge.svg)](https://github.com/JonathanWThom/agen/actions/workflows/main.yml)
4
4
 
5
- ## Roadmap
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
- $ bundle install
7
+ ## Installation & Usage
40
8
 
41
- Or install it yourself as:
9
+ Install with `gem install agen` and then run `agen` to build your aliases.
42
10
 
43
- $ gem install agen
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/[USERNAME]/agen.
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
@@ -19,7 +19,7 @@ module Agen
19
19
  .sort_by { |k, v| -v }
20
20
  .to_h
21
21
  .keys
22
- .select { |line| line.length >= min_chars }
22
+ .select { |cmd| cmd.length >= min_chars }
23
23
  .first(limit)
24
24
  end
25
25
 
data/lib/agen/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Agen
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Thom