Skip to content

Instantly share code, notes, and snippets.

@jonvuri
Created September 9, 2012 20:26
Show Gist options
  • Save jonvuri/3687048 to your computer and use it in GitHub Desktop.
Save jonvuri/3687048 to your computer and use it in GitHub Desktop.
#compdef _files
fuzzy_complete() {
words=( ${(z)BUFFER} );
pieces=( ${(s:/:)words[-1]} );
globpt=${(j:*:)${(s::)pieces[-1]}};
matches=( $pieces[1,-2]/*${~globpt}* );
(( $#matches == 1 )) && BUFFER="${words[1,-2]} ${matches[1]}" && CURSOR=$#BUFFER || zle -M "Completions: $matches"
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment