Skip to content

Instantly share code, notes, and snippets.

@theotheo
Last active March 21, 2018 17:48
Show Gist options
  • Save theotheo/6b339e306723f1c2555930460451f97d to your computer and use it in GitHub Desktop.
Save theotheo/6b339e306723f1c2555930460451f97d to your computer and use it in GitHub Desktop.
airflow bash completion
_airflow()
{
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# echo $prev
#
# The basic options we'll complete.
#
opts="flower pause resetdb upgradedb render
task_failed_deps backfill task_state list_tasks
clear worker version initdb dag_state connections
serve_logs list_dags test pool trigger_dag
variables run scheduler webserver unpause kerberos"
#
# Complete the arguments to some of the basic commands.
#
case "${prev}" in
list_tasks|trigger_dag|clear|dag_state)
local dags=$(for x in `airflow list_dags |
sed -z -n -e 's/^.*\(---\)//p'`; do echo $x; done)
COMPREPLY=( $(compgen -W "${dags}" -- ${cur}) )
return 0
;;
*)
;;
esac
COMPREPLY=( $( compgen -W "$opts" -- $cur))
return 0
}
complete -F _airflow airflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment