From a2ca08545d029ffb271ed04b501cc41a33d3c8f2 2013-11-12 23:52:24 From: Paul Ivanov Date: 2013-11-12 23:52:24 Subject: [PATCH] bash completion: generalize subcmd completer logic --- diff --git a/examples/core/ipython-completion.bash b/examples/core/ipython-completion.bash index 6a2ca57..3760e46 100644 --- a/examples/core/ipython-completion.bash +++ b/examples/core/ipython-completion.bash @@ -47,22 +47,18 @@ _ipython() opts="list create" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) elif [[ ${cur} == -* ]]; then - if [[ $mode == "notebook" ]]; then - _ipython_get_flags notebook - opts=$"${opts} ${baseopts}" - elif [[ $mode == "qtconsole" ]]; then - _ipython_get_flags qtconsole - opts="${opts} ${baseopts}" - elif [[ $mode == "console" ]]; then - _ipython_get_flags console - elif [[ $mode == "kernel" ]]; then - _ipython_get_flags kernel - opts="${opts} ${baseopts}" - elif [[ $mode == "locate" ]]; then - opts="" - else - opts=$baseopts - fi + case $mode in + "notebook" | "qtconsole" | "console" | "kernel") + _ipython_get_flags $mode + opts=$"${opts} ${baseopts}" + ;; + "locate" | "history" | "profile") + _ipython_get_flags $mode + opts=$"${opts}" + ;; + *) + opts=$baseopts + esac # don't drop the trailing space local IFS=$'\t\n' COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )