##// END OF EJS Templates
use help-all to get all options and add profile specializations
Julian Taylor -
Show More
@@ -1,73 +1,85 b''
1 1 # load with: . ipython-completion.bash
2 2
3 3 _ipython_get_flags()
4 4 {
5 5 local url=$1
6 6 local var=$2
7 7 local dash=$3
8 8 if [[ "$url $var" == $__ipython_complete_last ]]; then
9 9 opts=$__ipython_complete_last_res
10 10 return
11 11 fi
12 opts=$(cat <<EOF | python -
13 try:
14 import IPython.${url} as mod;
15 for k in mod.${var}:
16 print "${dash}%s" % k,
17 except:
18 pass
19 EOF
20 )
12 opts=$(ipython ${url} --help-all | grep -E "^-{1,2}[^-]" | sed -e "s/=.*//;s/ <.*//")
21 13 __ipython_complete_last="$url $var"
22 14 __ipython_complete_last_res="$opts"
23 15 }
24 16
25 17 _ipython()
26 18 {
27 19 local cur=${COMP_WORDS[COMP_CWORD]}
28 20 local prev=${COMP_WORDS[COMP_CWORD - 1]}
29 21 local subcommands="notebook qtconsole console kernel profile locate"
30 22 local opts=""
31 23 if [ -z "$__ipython_complete_baseopts" ]; then
32 24 _ipython_get_flags core.shellapp "shell_flags.keys()" "--"
33 25 __ipython_complete_baseopts="${opts}"
34 26 fi
35 27 local baseopts="$__ipython_complete_baseopts"
36 28 local mode=""
37 29 for i in "${COMP_WORDS[@]}"; do
38 30 [ "$cur" = "$i" ] && break
39 31 if [[ ${subcommands} == *${i}* ]]; then
40 32 mode="$i"
41 33 fi
42 34 done
43 35
44 36 if [[ ${cur} == -* ]]; then
45 37 if [[ $mode == "notebook" ]]; then
46 _ipython_get_flags frontend.html.notebook.notebookapp notebook_flags "--"
38 _ipython_get_flags notebook
47 39 opts=$"${opts} ${baseopts}"
48 40 elif [[ $mode == "qtconsole" ]]; then
49 _ipython_get_flags frontend.qt.console.qtconsoleapp qt_flags "--"
41 _ipython_get_flags qtconsole
50 42 opts="${opts} ${baseopts}"
51 43 elif [[ $mode == "console" ]]; then
52 _ipython_get_flags frontend.terminal.console.app frontend_flags "--"
44 _ipython_get_flags console
53 45 elif [[ $mode == "kernel" ]]; then
54 _ipython_get_flags zmq.kernelapp "kernel_flags.keys()" "--"
46 _ipython_get_flags kernel
55 47 opts="${opts} ${baseopts}"
48 elif [[ $mode == "profile" ]]; then
49 opts="list create"
50 elif [[ $mode == "locate" ]]; then
51 opts=""
56 52 else
57 53 opts=$baseopts
58 54 fi
59 55 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
60 56 return 0
61 57 elif [[ ${prev} == "--pylab"* ]] || [[ ${prev} == "--gui"* ]]; then
62 58 _ipython_get_flags core.shellapp InteractiveShellApp.pylab.values
63 59 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
60 elif [[ ${prev} == "--profile"* ]]; then
61 if [ -z "$__ipython_complete_profiles" ]; then
62 __ipython_complete_profiles=$(cat <<EOF | python -
63 try:
64 import IPython.core.profileapp
65 for k in IPython.core.profileapp.list_bundled_profiles():
66 print "%s" % k,
67 p = IPython.core.profileapp.ProfileList()
68 for k in IPython.core.profileapp.list_profiles_in(p.ipython_dir):
69 print "%s" % k,
70 except:
71 pass
72 EOF
73 )
74 fi
75 COMPREPLY=( $(compgen -W "${__ipython_complete_profiles}" -- ${cur}) )
64 76 else
65 77 if [ -z "$mode" ]; then
66 78 COMPREPLY=( $(compgen -f -W "${subcommands}" -- ${cur}) )
67 79 else
68 80 COMPREPLY=( $(compgen -f -- ${cur}) )
69 81 fi
70 82 fi
71 83
72 84 }
73 85 complete -o default -F _ipython ipython
General Comments 0
You need to be logged in to leave comments. Login now