Skip to content
HuffShell is a gem for suggesting and optimizing your shell aliases, programtically.
Ruby Shell
Find file
Latest commit 79e9285 Dec 23, 2015 @paulmars Merge pull request #19 from bfontaine/mit
MIT license added
Failed to load latest commit information.
bin throw error message if history file is unreadable. Nov 8, 2012
lib throw error message if history file is unreadable. Nov 8, 2012
.gitignore remove rbenv from repo Jun 25, 2012
.rspec add spec environment to repo Jun 18, 2012
Gemfile add coverage to repo, add gem dependency Jun 20, 2012
Gemfile.lock correctly a bad build process released in version 0.0.12 Aug 20, 2012
LICENSE MIT license added Dec 23, 2015
Rakefile rbenv details Mar 13, 2014 rename to huffshell Jun 19, 2012
huffshell.gemspec MIT license added Dec 23, 2015 bump gemfile stats Nov 8, 2012 change build script to make it reinstall Jun 19, 2012


Huffshell is a gem for suggesting new aliases, programmatically.

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.

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.

Additionally, huffshell prints out stats on what your usage for people who are just curious.

No changes are made to your shell. Only recommendations are printed to screen.


  • Alias suggestion based on history.
  • Examines your system for binaries and aliases and avoids reassigning them.
  • Huffman inspired symbol generation.
  • Handy gem packaging.
  • Works with Bash history & Zsh history
  • Works out of the box with oh-my-zsh (datetime history).


Here is how you install the gem.

# install the gem (sudo is optional)
sudo gem install huffshell

# need to be able to access this from the gem
alias > ~/.aliases.cache

# open up a new terminal to access new gem supplied binaries
# or possible run "rbenv hash" if you use rbenv

# Optional cleanup
rm ~/.aliases.cache


gem update huffshell



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.

## Command history configuration

setopt append_history
setopt extended_history
# setopt hist_expire_dups_first
# setopt hist_ignore_dups # ignore duplication command history list
setopt hist_ignore_space
setopt hist_verify
setopt inc_append_history
# setopt share_history # share command history data

Can't I just do this in the shell?

Sort of, but not very well:


history 1 | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr 

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 (since line 1) but returns only 1 line of history in bash (relative).


history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr 
Something went wrong with that request. Please try again.