Last active
March 25, 2017 10:29
-
-
Save bjhaid/ee6246d4cdb8749d7b6f to your computer and use it in GitHub Desktop.
Bash Auto Completion for elixir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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