From 5ef936325e24c5eccc708efd033dc70b39804fae 2013-11-15 00:39:51 From: Paul Ivanov Date: 2013-11-15 00:39:51 Subject: [PATCH] bash completion: proper history completion --- diff --git a/examples/core/ipython-completion.bash b/examples/core/ipython-completion.bash index 2554a60..c875dad 100644 --- a/examples/core/ipython-completion.bash +++ b/examples/core/ipython-completion.bash @@ -50,8 +50,16 @@ _ipython() _ipython_get_flags $mode opts=$"${opts} ${baseopts}" ;; - "locate" | "history" | "profile") + "locate" | "profile") _ipython_get_flags $mode + ;; + "history") + if [[ "${COMP_WORDS[2]}" == "trim" ]]; then + _ipython_get_flags "history trim" + else + _ipython_get_flags $mode + + fi opts=$"${opts}" ;; *) @@ -65,8 +73,11 @@ _ipython() opts="list create locate" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) elif [[ $mode == "history" ]]; then - opts="trim" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + if [[ "${COMP_WORDS[2]}" == "trim" ]]; then + COMPREPLY="--" + else + COMPREPLY="trim " + fi elif [[ $mode == "locate" ]]; then opts="profile" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )