Show More
@@ -1,37 +1,38 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | |
|
3 | 3 | |
|
4 | 4 | """ |
|
5 | 5 | Add %global magic for GNU Global usage. |
|
6 | 6 | |
|
7 | 7 | http://www.gnu.org/software/global/ |
|
8 | 8 | |
|
9 | 9 | """ |
|
10 | 10 | |
|
11 | 11 | import IPython.ipapi |
|
12 | 12 | ip = IPython.ipapi.get() |
|
13 | 13 | import os |
|
14 | 14 | |
|
15 | 15 | # alter to your liking |
|
16 | 16 | global_bin = 'd:/opt/global/bin/global' |
|
17 | 17 | |
|
18 | 18 | def global_f(self,cmdline): |
|
19 | 19 | simple = 0 |
|
20 | 20 | if '-' not in cmdline: |
|
21 | 21 | cmdline = '-rx ' + cmdline |
|
22 | 22 | simple = 1 |
|
23 | 23 | |
|
24 | lines = os.popen( global_bin + ' ' + cmdline ).readlines() | |
|
24 | lines = [l.rstrip() for l in os.popen( global_bin + ' ' + cmdline ).readlines()] | |
|
25 | ||
|
25 | 26 | if simple: |
|
26 | 27 | parts = [l.split(None,3) for l in lines] |
|
27 | 28 | lines = ['%s [%s]\n%s' % (p[2].rjust(70),p[1],p[3].rstrip()) for p in parts] |
|
28 | 29 | print "\n".join(lines) |
|
29 | 30 | |
|
30 | 31 | ip.expose_magic('global', global_f) |
|
31 | 32 | |
|
32 | 33 | def global_completer(self,event): |
|
33 | 34 | compl = [l.rstrip() for l in os.popen(global_bin + ' -c ' + event.symbol).readlines()] |
|
34 | 35 | return compl |
|
35 | 36 | |
|
36 | 37 | ip.set_hook('complete_command', global_completer, str_key = '%global') |
|
37 | 38 |
General Comments 0
You need to be logged in to leave comments.
Login now