huffshell 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/Readme.md +29 -6
  2. data/bin/huffshell +10 -6
  3. metadata +4 -4
data/Readme.md CHANGED
@@ -3,7 +3,7 @@ Huffshell
3
3
 
4
4
  Huffshell is a gem for suggesting new aliases, programmatically.
5
5
 
6
- Huffshell looks at your shell history and suggests aliases based on your typical usage. Memorable and short commands are suggested for the most common things you type to save you the most keystrokes.
6
+ Huffshell looks at your shell history (bash/zsh/generic) and suggests aliases based on your typical usage. Memorable and short commands are suggested for the most common things you type to save you the most keystrokes.
7
7
 
8
8
  For example, if you type 'git' 500 times and 'ls -l' 100 times, good aliases might be 'g' and 'll'. It could save you hundreds of keystrokes.
9
9
 
@@ -18,7 +18,8 @@ Features
18
18
  * Examines your system for binaries and aliases and avoids reassigning them.
19
19
  * Huffman inspired symbol generation.
20
20
  * Handy gem packaging.
21
- * Works out of the box with oh-my-zsh.
21
+ * Works with Bash history & Zsh history
22
+ * Works out of the box with oh-my-zsh (datetime history).
22
23
 
23
24
  Installation
24
25
  ---------------------
@@ -26,15 +27,17 @@ Installation
26
27
  Here is how you install the gem.
27
28
 
28
29
  ```script
29
- # install the gem
30
- gem install huffshell
30
+ # install the gem (sudo is optional)
31
+ sudo gem install huffshell
31
32
 
32
33
  # need to be able to access this from the gem
33
34
  alias > ~/.aliases.cache
35
+
36
+ # open up a new terminal to access new gem supplied binaries
34
37
  huffshell
35
38
 
36
39
  # Optional cleanup
37
- alias > ~/.aliases.cache
40
+ rm ~/.aliases.cache
38
41
  ```
39
42
 
40
43
  Update
@@ -44,9 +47,11 @@ Update
44
47
  gem update huffshell
45
48
  ````
46
49
 
47
- De-duplication
50
+ Questions
48
51
  ---------------------
49
52
 
53
+ ###De-duplication?
54
+
50
55
  Many people have some form of de-duplication on their ZSH history. That is a great feature but will prevent you from getting all of the benefits of alias generation. If you are curious and want to see a better picture of your shell usage, here is a zsh configuration which remove de-duping and creates a more accurate picture.
51
56
 
52
57
  ```script
@@ -64,3 +69,21 @@ setopt hist_verify
64
69
  setopt inc_append_history
65
70
  # setopt share_history # share command history data
66
71
  ```
72
+
73
+ ### Can't I just do this in the shell?
74
+
75
+ Sort of, but not very well:
76
+
77
+ ZSH:
78
+ ```script
79
+ history 1 | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr
80
+ ```
81
+
82
+ Depending on your environment, you may want to change "history 1" to "history" in the previous command. "history 1" returns the complete history on my system
83
+ (since line 1) but returns only 1 line of history in bash (relative).
84
+
85
+ BASH:
86
+ ```script
87
+ history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr
88
+ ```
89
+
@@ -10,13 +10,17 @@ puts "============="
10
10
  history_files = HistoryReader.files
11
11
 
12
12
  history_files.each do |history_filename|
13
- if HistoryReader.timestamps?(history_filename)
14
- shell_commands = OhMyZshReader.new(history_filename).shell_commands
15
- else
16
- shell_commands = HistoryReader.new(history_filename).shell_commands
13
+ begin
14
+ if HistoryReader.timestamps?(history_filename)
15
+ shell_commands = OhMyZshReader.new(history_filename).shell_commands
16
+ else
17
+ shell_commands = HistoryReader.new(history_filename).shell_commands
18
+ end
19
+ puts "Importing #{history_filename} #{shell_commands.size} commands found"
20
+ shell_commands.each{ |l| cs.add(l) }
21
+ rescue
22
+ puts "#{history_filename} is unreadable."
17
23
  end
18
- puts "Importing #{history_filename} #{shell_commands.size} commands found"
19
- shell_commands.each{ |l| cs.add(l) }
20
24
  end
21
25
 
22
26
  puts cs.wordtree.root.line_count
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: huffshell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-20 00:00:00.000000000Z
12
+ date: 2012-11-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
16
- requirement: &70309312392800 !ruby/object:Gem::Requirement
16
+ requirement: &70108321800860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70309312392800
24
+ version_requirements: *70108321800860
25
25
  description: A parser and recommendation system for your shell aliases based on your
26
26
  shell history
27
27
  email: paul.mckellar@gmail.com