Show More
@@ -184,12 +184,13 b" ip.set_hook('complete_command', runlistpy, str_key = '%run')" | |||
|
184 | 184 | |
|
185 | 185 | def cd_completer(self, event): |
|
186 | 186 | relpath = event.symbol |
|
187 | ||
|
187 | # print event # dbg | |
|
188 | 188 | if '-b' in event.line: |
|
189 | 189 | # return only bookmark completions |
|
190 | 190 | bkms = self.db.get('bookmarks',{}) |
|
191 | 191 | return bkms.keys() |
|
192 | 192 | |
|
193 | ||
|
193 | 194 | if event.symbol == '-': |
|
194 | 195 | # jump in directory history by number |
|
195 | 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 | 198 | return ents |
|
198 | 199 | return [] |
|
199 | 200 | |
|
201 | if sys.platform != 'win32': | |
|
202 | protect = lambda n: n | |
|
203 | else: | |
|
204 | def protect(n): | |
|
205 | return n.replace('\\' ,'/').replace(' ', '\\ ') | |
|
200 | 206 | |
|
201 | 207 | if relpath.startswith('~'): |
|
202 | 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 | 211 | if not found: |
|
212 | if os.path.isdir(relpath): | |
|
205 | 213 | return [relpath] |
|
214 | raise IPython.ipapi.TryNext | |
|
206 | 215 | return found |
|
207 | 216 | |
|
208 | 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