##// END OF EJS Templates
replace $() with backticks...
Julian Taylor -
Show More
@@ -1,106 +1,106 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 12 # pylab and profile don't need the = and the
13 13 # version without simplifies the special cased completion
14 14 opts=$(ipython ${url} --help-all | grep -E "^-{1,2}[^-]" | sed -e "s/<.*//" -e "s/[^=]$/& /" -e "s/^--pylab=$//" -e "s/^--profile=$/--profile /")
15 15 __ipython_complete_last="$url $var"
16 16 __ipython_complete_last_res="$opts"
17 17 }
18 18
19 19 _ipython()
20 20 {
21 21 local cur=${COMP_WORDS[COMP_CWORD]}
22 22 local prev=${COMP_WORDS[COMP_CWORD - 1]}
23 23 local subcommands="notebook qtconsole console kernel profile locate"
24 24 local opts=""
25 25 if [ -z "$__ipython_complete_baseopts" ]; then
26 26 _ipython_get_flags baseopts
27 27 __ipython_complete_baseopts="${opts}"
28 28 fi
29 29 local baseopts="$__ipython_complete_baseopts"
30 30 local mode=""
31 31 for i in "${COMP_WORDS[@]}"; do
32 32 [ "$cur" = "$i" ] && break
33 33 if [[ ${subcommands} == *${i}* ]]; then
34 34 mode="$i"
35 35 break
36 36 elif [[ ${i} == "--"* ]]; then
37 37 mode="nosubcommand"
38 38 break
39 39 fi
40 40 done
41 41
42 42 if [[ $mode == "profile" ]]; then
43 43 opts="list create"
44 44 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
45 45 elif [[ ${cur} == -* ]]; then
46 46 if [[ $mode == "notebook" ]]; then
47 47 _ipython_get_flags notebook
48 48 opts=$"${opts} ${baseopts}"
49 49 elif [[ $mode == "qtconsole" ]]; then
50 50 _ipython_get_flags qtconsole
51 51 opts="${opts} ${baseopts}"
52 52 elif [[ $mode == "console" ]]; then
53 53 _ipython_get_flags console
54 54 elif [[ $mode == "kernel" ]]; then
55 55 _ipython_get_flags kernel
56 56 opts="${opts} ${baseopts}"
57 57 elif [[ $mode == "locate" ]]; then
58 58 opts=""
59 59 else
60 60 opts=$baseopts
61 61 fi
62 62 # don't drop the trailing space
63 63 local IFS=$'\t\n'
64 64 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
65 65 return 0
66 66 elif [[ ${prev} == "--pylab"* ]] || [[ ${prev} == "--gui"* ]]; then
67 67 if [ -z "$__ipython_complete_pylab" ]; then
68 __ipython_complete_pylab=$(cat <<EOF | python -
68 __ipython_complete_pylab=`cat <<EOF | python -
69 69 try:
70 70 import IPython.core.shellapp as mod;
71 71 for k in mod.InteractiveShellApp.pylab.values:
72 72 print "%s " % k
73 73 except:
74 74 pass
75 75 EOF
76 )
76 `
77 77 fi
78 78 local IFS=$'\t\n'
79 79 COMPREPLY=( $(compgen -W "${__ipython_complete_pylab}" -- ${cur}) )
80 80 elif [[ ${prev} == "--profile"* ]]; then
81 81 if [ -z "$__ipython_complete_profiles" ]; then
82 __ipython_complete_profiles=$(cat <<EOF | python -
82 __ipython_complete_profiles=`cat <<EOF | python -
83 83 try:
84 84 import IPython.core.profileapp
85 85 for k in IPython.core.profileapp.list_bundled_profiles():
86 86 print "%s " % k
87 87 p = IPython.core.profileapp.ProfileList()
88 88 for k in IPython.core.profileapp.list_profiles_in(p.ipython_dir):
89 89 print "%s " % k
90 90 except:
91 91 pass
92 92 EOF
93 )
93 `
94 94 fi
95 95 local IFS=$'\t\n'
96 96 COMPREPLY=( $(compgen -W "${__ipython_complete_profiles}" -- ${cur}) )
97 97 else
98 98 if [ -z "$mode" ]; then
99 99 COMPREPLY=( $(compgen -f -W "${subcommands}" -- ${cur}) )
100 100 else
101 101 COMPREPLY=( $(compgen -f -- ${cur}) )
102 102 fi
103 103 fi
104 104
105 105 }
106 106 complete -o default -o nospace -F _ipython ipython
General Comments 0
You need to be logged in to leave comments. Login now