huffshell 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.md +30 -1
- data/bin/huffshell +20 -1
- data/lib/command/command_suggestor.rb +4 -0
- data/lib/tree/word_tree_node.rb +4 -0
- metadata +1 -1
data/Readme.md
CHANGED
@@ -21,6 +21,14 @@ Features
|
|
21
21
|
Installation
|
22
22
|
---------------------
|
23
23
|
|
24
|
+
You need to have zsh_history stored at this location: '~/.zsh_history'. If this code outputs a lot of junk, you are probably setup.
|
25
|
+
|
26
|
+
```script
|
27
|
+
cat ~/.zsh_history
|
28
|
+
```
|
29
|
+
|
30
|
+
Here is how you install the gem.
|
31
|
+
|
24
32
|
```script
|
25
33
|
# install it
|
26
34
|
gem install huffman
|
@@ -31,4 +39,25 @@ huffshell
|
|
31
39
|
|
32
40
|
# cleanup
|
33
41
|
alias > ~/.aliases.cache
|
34
|
-
```
|
42
|
+
```
|
43
|
+
|
44
|
+
Fixes
|
45
|
+
---------------------
|
46
|
+
|
47
|
+
Things don't look right? Change your zsh history to these settings to allow your history to save dups and store a lot of entries. You need dups so that we can figure out what to optimize out with aliases and the larger the history, the better the data will be.
|
48
|
+
|
49
|
+
```script
|
50
|
+
## Command history configuration
|
51
|
+
HISTFILE=$HOME/.zsh_history
|
52
|
+
HISTSIZE=20000
|
53
|
+
SAVEHIST=20000
|
54
|
+
|
55
|
+
setopt append_history
|
56
|
+
setopt extended_history
|
57
|
+
# setopt hist_expire_dups_first
|
58
|
+
# setopt hist_ignore_dups # ignore duplication command history list
|
59
|
+
setopt hist_ignore_space
|
60
|
+
setopt hist_verify
|
61
|
+
setopt inc_append_history
|
62
|
+
# setopt share_history # share command history data
|
63
|
+
```
|
data/bin/huffshell
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'huffshell'
|
4
|
-
require '
|
4
|
+
require 'colorize'
|
5
5
|
|
6
6
|
cs = CommandSuggestor.new
|
7
7
|
history_filename = '~/.zsh_history'
|
@@ -10,5 +10,24 @@ OhMyZshReader.new(history_filename).
|
|
10
10
|
shell_commands.
|
11
11
|
each{ |l| cs.add(l) }
|
12
12
|
|
13
|
+
puts "Huffshel"
|
14
|
+
puts "============="
|
15
|
+
puts [cs.commands.size.to_s.green, "unique keywords"].join(" ")
|
16
|
+
|
17
|
+
puts ""
|
18
|
+
[250, 100, 50, 20, 10, 5, 2, 1].reverse.each do |count|
|
19
|
+
puts [cs.wordtree.root.minimum(count).keys.size.to_s.green, "commands appear > #{count} times"].join(" ")
|
20
|
+
end
|
21
|
+
|
22
|
+
puts ""
|
23
|
+
puts "Most common commands:"
|
24
|
+
|
25
|
+
cs.wordtree.root.minimum(10).sort{|a, b| a[1].line_count <=> b[1].line_count }.reverse[0,10].each do |word, node|
|
26
|
+
puts [node.word, node.line_count.to_s.green].join(" ")
|
27
|
+
end
|
28
|
+
|
13
29
|
cs.truncate!(30)
|
30
|
+
|
31
|
+
puts ""
|
32
|
+
puts "Command tree:"
|
14
33
|
puts cs.to_print
|
data/lib/tree/word_tree_node.rb
CHANGED