Skip to content

Instantly share code, notes, and snippets.

@mschuerig
Created June 14, 2012 08:36
Show Gist options
  • Save mschuerig/2929081 to your computer and use it in GitHub Desktop.
Save mschuerig/2929081 to your computer and use it in GitHub Desktop.
Bash completion for cheat
_cheat()
{
local sheets
list="$HOME/.cheat/.sheets"
if [ ! -f "$list" ]; then
cheat sheets | sed -n 's/^ \(.*\)$/\1/p' > "$list"
fi
sheets=$(cat "$list")
COMPREPLY=($(compgen -W "${sheets}" -- ${COMP_WORDS[COMP_CWORD]}))
}
complete -F _cheat cheat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment