Skip to content

Instantly share code, notes, and snippets.

@bjhaid
Last active March 25, 2017 10:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjhaid/ee6246d4cdb8749d7b6f to your computer and use it in GitHub Desktop.
Save bjhaid/ee6246d4cdb8749d7b6f to your computer and use it in GitHub Desktop.
Bash Auto Completion for elixir
_mix()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ ! -f /tmp/__mix_completion__ ]]; then
opts=$(for i in `mix help | grep -ve "current:" | grep -ve "iex" | awk '{ print $2" " }'`; do echo $i; done);
echo $opts > /tmp/__mix_completion__;
else
opts=$(cat /tmp/__mix_completion__);
fi
if [[ ${prev} == mix ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) );
return 0;
fi
}
_iex()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ ! -f /tmp/__iex_completion__ ]]; then
opts=$(for i in `iex --help 2>&1 >/dev/null | grep -e '^ *-' | awk '{ print $1 }'`; do echo $i; done);
echo $opts > /tmp/__iex_completion__;
else
opts=$(cat /tmp/__iex_completion__);
fi
if [[ ${prev} == iex ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) );
return 0;
fi
}
_elixir()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ ! -f /tmp/__elixir_completion__ ]]; then
opts=$(for i in `elixir --help 2>&1 >/dev/null | grep -e '^ *-' | awk '{ print $1 }'`; do echo $i; done);
echo $opts > /tmp/__elixir_completion__;
else
opts=$(cat /tmp/__elixir_completion__);
fi
if [[ ${prev} == elixir ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) );
return 0;
fi
}
complete -F _mix mix
complete -F _elixir elixir
complete -F _iex iex
_elixir()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ ! -f /tmp/__elixir_completion__ ]]; then
opts=$(for i in `elixir --help 2>&1 >/dev/null | grep -e '^ *-' | awk '{ print $1 }'`; do echo $i; done);
echo $opts > /tmp/__elixir_completion__;
else
opts=$(cat /tmp/__elixir_completion__);
fi
if [[ ${prev} == elixir ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) );
return 0;
fi
}
complete -F _elixir elixir
_iex()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ ! -f /tmp/__iex_completion__ ]]; then
opts=$(for i in `iex --help 2>&1 >/dev/null | grep -e '^ *-' | awk '{ print $1 }'`; do echo $i; done);
echo $opts > /tmp/__iex_completion__;
else
opts=$(cat /tmp/__iex_completion__);
fi
if [[ ${prev} == iex ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) );
return 0;
fi
}
complete -F _iex iex
_mix()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ ! -f /tmp/__mix_completion__ ]]; then
opts=$(for i in `mix help | grep -ve "current:" | grep -ve "iex" | awk '{ print $2" " }'`; do echo $i; done);
echo $opts > /tmp/__mix_completion__;
else
opts=$(cat /tmp/__mix_completion__);
fi
if [[ ${prev} == mix ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) );
return 0;
fi
}
complete -F _mix mix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment