DEV Community

Lubien
Lubien

Posted on

Elixir mix + fzf = ๐Ÿ’œ๐Ÿงช

asciicast

fzf is such a powerful tool when it comes to make your terminal experiences so much better. One thing I like about it is how easy it is to extend it's features and one could make auto completions work for any command with bare minimum code.

For today's snippet I'd like to share, here's how to integrate Elixir's build tool mix with it. Just paste it on your friendly neighborhood dotfiles (.bashrc, .zshrc...) and git it a go by writting mix ** then hitting <Tab>.

_fzf_complete_mix() {
  _fzf_complete --reverse -- "$@" < <(
    mix help | \
        grep "^mix [a-zA-Z]" --color=never | \
        sed "s/^[^ ]* //" | \
        sed "s/#.*//" 
  )
}

_fzf_complete_mix_post() {
  awk '{print $NF}'
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)