minor fixes

pull/29/head
Joël Schaerer 14 years ago
parent 82d3e14c1f
commit d6f398858c

@ -1,27 +1,30 @@
# This module was contributed by Mario Pastorelli <pastorelli.mario@gmail.com>
# It is released in the public domain
# This tool provides "j" for ipython
# To use it, copy it in your ~/.ipython directory
# and add the following line to ipy_user_conf.py:
# import autojump_ipython
import os
import subprocess as sub
from IPython.ipapi import get
from IPython.iplib import InteractiveShell
# Export the environment variable pointing to the autojump storage dir
ip = get()
ip.magic('env AUTOJUMP_DATA_DIR=/home/rief/.local/share/autojump')
def magic_j(self,parameter_s=''):
cmd = ['autojump']+parameter_s.split()
# print 'executing autojump with args %s' % str(cmd)
# print 'executing autojump with args %s' % str(cmd)
newpath=sub.Popen(cmd,stdout=sub.PIPE,shell=False).communicate()[0][:-1] # delete last '\n'
# print 'Autojump answer: \'%s\'' % newpath
ip.magic('cd \'%s\'' % newpath)
# print 'Autojump answer: \'%s\'' % newpath
if newpath:
ip.magic('cd \'%s\'' % newpath)
def cd_decorator(f):
def autojump_cd_monitor(self,parameter_s=''):
f(self,parameter_s)
# print 'Calling autojump -a '+str(parameter_s.split())
sub.call(['autojump','-a']+parameter_s.split())
sub.call(['autojump','-a',os.getcwd()])
return autojump_cd_monitor
# Add the new magic function to the class dict and decorate magic_cd:

Loading…
Cancel
Save