Show More
@@ -184,12 +184,13 b" ip.set_hook('complete_command', runlistpy, str_key = '%run')" | |||||
184 |
|
184 | |||
185 | def cd_completer(self, event): |
|
185 | def cd_completer(self, event): | |
186 | relpath = event.symbol |
|
186 | relpath = event.symbol | |
187 |
|
187 | # print event # dbg | ||
188 | if '-b' in event.line: |
|
188 | if '-b' in event.line: | |
189 | # return only bookmark completions |
|
189 | # return only bookmark completions | |
190 | bkms = self.db.get('bookmarks',{}) |
|
190 | bkms = self.db.get('bookmarks',{}) | |
191 | return bkms.keys() |
|
191 | return bkms.keys() | |
192 |
|
192 | |||
|
193 | ||||
193 | if event.symbol == '-': |
|
194 | if event.symbol == '-': | |
194 | # jump in directory history by number |
|
195 | # jump in directory history by number | |
195 | ents = ['-%d [%s]' % (i,s) for i,s in enumerate(ip.user_ns['_dh'])] |
|
196 | ents = ['-%d [%s]' % (i,s) for i,s in enumerate(ip.user_ns['_dh'])] | |
@@ -197,12 +198,20 b' def cd_completer(self, event):' | |||||
197 | return ents |
|
198 | return ents | |
198 | return [] |
|
199 | return [] | |
199 |
|
200 | |||
200 |
|
201 | if sys.platform != 'win32': | ||
|
202 | protect = lambda n: n | |||
|
203 | else: | |||
|
204 | def protect(n): | |||
|
205 | return n.replace('\\' ,'/').replace(' ', '\\ ') | |||
|
206 | ||||
201 | if relpath.startswith('~'): |
|
207 | if relpath.startswith('~'): | |
202 | relpath = os.path.expanduser(relpath).replace('\\','/') |
|
208 | relpath = os.path.expanduser(relpath).replace('\\','/') | |
203 |
found = [f |
|
209 | found = [protect(f)+'/' for f in glob.glob(relpath+'*') if os.path.isdir(f)] | |
|
210 | # print "f",found # dbg | |||
204 | if not found: |
|
211 | if not found: | |
205 | return [relpath] |
|
212 | if os.path.isdir(relpath): | |
|
213 | return [relpath] | |||
|
214 | raise IPython.ipapi.TryNext | |||
206 | return found |
|
215 | return found | |
207 |
|
216 | |||
208 | ip.set_hook('complete_command', cd_completer, str_key = '%cd') |
|
217 | ip.set_hook('complete_command', cd_completer, str_key = '%cd') |
General Comments 0
You need to be logged in to leave comments.
Login now