[IPython-user] Custom command completers implemented in SVN

Ville M. Vainio vivainio at gmail.com
Thu Nov 2 04:06:18 CST 2006


On 10/31/06, John Hunter <jdhunter at ace.bsd.uchicago.edu> wrote:

> import os, glob
> def listdirs(self, event):
>     cd, relpath = event['line'].split(' ', 1)
>     if relpath.startswith('~'):
>         relpath = os.path.expanduser(relpath)
>     return [f for f in  glob.glob(relpath+'*') if os.path.isdir(f)]
>
> ip.set_hook('complete_command', listdirs, re_key = 'cd .*')
>
> def runlistpy(self, event):
>     relpath = event['line'].split(' ')[-1]
>     if relpath.startswith('~'):
>         relpath = os.path.expanduser(relpath)
>     dirs = [f for f in  glob.glob(relpath+'*') if os.path.isdir(f)]
>     pys =  [f for f in  glob.glob(relpath+'*.py')]
>     return dirs + pys

I have added slightly tweaked (more win32-friendly) versions of these
to ipy_stock_completers.py.

Also, the stock completers are now installed in default
ipy_user_config.py. Run %upgrade to get the wheels rolling.

Esp. the %cd completer really is a major comfort improvement in shell
usage, everyone should try it out!

-- 
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'


More information about the IPython-user mailing list