agen 0.3.1 → 0.3.2
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/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -1
- data/lib/agen/finder.rb +13 -1
- data/lib/agen/runner.rb +14 -3
- data/lib/agen/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed987efd2447a05d6ae754c1213294c75b83076223b8a86ba19f920c5dc8f9a6
|
4
|
+
data.tar.gz: 90e0549611cc1a2849100ff5659ae4cbc4607a4492b9d8d0f438265baff8a496
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21298d135a781bcc0b86417fb651371058103fb3004941686db63311464ab19d6c17dab56fa5dba24eff32cb2a86b21a745f6e7e1abfc9ce2293d20b692cc471
|
7
|
+
data.tar.gz: 706f73381f921ac29b7a3ca858040b4d8bfe253829824b3b653a28e5d7d45a11f5b44b9b3ff32d5d00469c072823004e9431548513503a415666bc1a5c29116a
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -25,6 +25,9 @@ Usage: agen [options]
|
|
25
25
|
Right now, this will only work with `zsh` or `bash`, but you can specify unique shell config files using the `-r` and `-h` options (though there is no guarantee that your history file will be read properly). By default, agen reads from `.zsh_history` and
|
26
26
|
writes to `.zshrc`.
|
27
27
|
|
28
|
+
When editing aliases interactively (which is the default), any commands that are
|
29
|
+
ignored (via the `i` command) will be stored in the ~/.agen configuration file.
|
30
|
+
|
28
31
|
## Development
|
29
32
|
|
30
33
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -37,10 +40,10 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Jonath
|
|
37
40
|
|
38
41
|
## Roadmap
|
39
42
|
|
40
|
-
* CLI will let you "ignore" commands you don't want to alias, forever.
|
41
43
|
* CLI will raise user friendly errors if you specify shell configuration files that don't exist.
|
42
44
|
* CLI will let you specify "meta" vs "full" commands.
|
43
45
|
- Full command would be `git checkout branch-name`, meta command would be `git checkout`.
|
46
|
+
* Update video in README to reflect `i` command.
|
44
47
|
|
45
48
|
## License
|
46
49
|
|
data/lib/agen/finder.rb
CHANGED
@@ -5,8 +5,9 @@ module Agen
|
|
5
5
|
LIMIT = 5
|
6
6
|
MIN_CHARS = 6
|
7
7
|
|
8
|
-
def initialize(histfile)
|
8
|
+
def initialize(histfile, config_file = Runner::CONFIG_FILE)
|
9
9
|
@histfile = histfile
|
10
|
+
@config_file = config_file
|
10
11
|
end
|
11
12
|
|
12
13
|
def commands(limit: LIMIT, min_chars: MIN_CHARS)
|
@@ -21,11 +22,22 @@ module Agen
|
|
21
22
|
.to_h
|
22
23
|
.keys
|
23
24
|
.select { |cmd| cmd.length >= min_chars }
|
25
|
+
.select { |cmd| !ignored?(cmd) }
|
24
26
|
.first(limit)
|
25
27
|
end
|
26
28
|
|
27
29
|
private
|
28
30
|
|
31
|
+
attr_reader :config_file
|
32
|
+
|
33
|
+
def ignored?(cmd)
|
34
|
+
File.readlines(config_file).detect do |line|
|
35
|
+
line.delete("\n") == cmd
|
36
|
+
end
|
37
|
+
rescue Errno::ENOENT
|
38
|
+
# User hasn't ignored anything yet, so doesn't have a config file
|
39
|
+
end
|
40
|
+
|
29
41
|
def lines
|
30
42
|
File.readlines(@histfile).reverse
|
31
43
|
end
|
data/lib/agen/runner.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Agen
|
4
4
|
class Runner
|
5
|
+
CONFIG_FILE = "#{Dir.home}/.agen"
|
5
6
|
DEFAULT_HISTFILE = ZshOptions::HISTFILE
|
6
7
|
DEFAULT_RCFILE = ZshOptions::RCFILE
|
7
8
|
DEFAULT_NUMBER = 5
|
@@ -12,12 +13,14 @@ module Agen
|
|
12
13
|
histfile: DEFAULT_HISTFILE,
|
13
14
|
rcfile: DEFAULT_RCFILE,
|
14
15
|
number: DEFAULT_NUMBER,
|
15
|
-
auto: false
|
16
|
+
auto: false,
|
17
|
+
config_file: CONFIG_FILE
|
16
18
|
)
|
17
19
|
@histfile = histfile
|
18
20
|
@rcfile = rcfile
|
19
21
|
@number = number
|
20
22
|
@auto = auto
|
23
|
+
@config_file = config_file
|
21
24
|
end
|
22
25
|
|
23
26
|
def run
|
@@ -40,7 +43,7 @@ module Agen
|
|
40
43
|
|
41
44
|
private
|
42
45
|
|
43
|
-
attr_reader :auto, :builder
|
46
|
+
attr_reader :auto, :builder, :config_file
|
44
47
|
|
45
48
|
def write_auto(file, full_alias)
|
46
49
|
puts full_alias
|
@@ -49,13 +52,15 @@ module Agen
|
|
49
52
|
|
50
53
|
def write_interactive(file, aliaz)
|
51
54
|
puts "Proposed alias: #{aliaz[:full_alias]}"
|
52
|
-
print "Accept? [n to reject, m to modify alias, any other key to accept]: "
|
55
|
+
print "Accept? [n to reject, m to modify alias, i to ignore forever, any other key to accept]: "
|
53
56
|
response = gets.chomp
|
54
57
|
case response
|
55
58
|
when "n"
|
56
59
|
puts "Alias skipped"
|
57
60
|
when "m"
|
58
61
|
modify_alias(file, aliaz)
|
62
|
+
when "i"
|
63
|
+
ignore_alias(aliaz)
|
59
64
|
else
|
60
65
|
file.puts(aliaz[:full_alias])
|
61
66
|
puts "Alias written"
|
@@ -64,6 +69,12 @@ module Agen
|
|
64
69
|
puts
|
65
70
|
end
|
66
71
|
|
72
|
+
def ignore_alias(aliaz)
|
73
|
+
command = aliaz[:command]
|
74
|
+
File.open(config_file, "a") { |f| f.puts(command) }
|
75
|
+
puts "Ignoring command '#{command}' forever"
|
76
|
+
end
|
77
|
+
|
67
78
|
def modify_alias(file, aliaz)
|
68
79
|
print "Enter new alias [replacing #{aliaz[:alias]}]: "
|
69
80
|
replacement = gets.chomp
|
data/lib/agen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Thom
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|