##// END OF EJS Templates
add ipy_workdir
vivainio -
Show More
@@ -0,0 +1,31 b''
1 #!/usr/bin/env python
2
3 import IPython.ipapi
4 ip = IPython.ipapi.get()
5
6 import os
7
8 workdir = None
9 def workdir_f(line):
10 global workdir
11 dummy,cmd = line.split(None,1)
12 if os.path.isdir(cmd):
13 workdir = cmd
14 print "Set workdir",workdir
15 elif workdir is None:
16 print "Please set workdir first by doing e.g. 'workdir q:/'"
17 else:
18 print "Execute command in",workdir
19 cwd = os.getcwd()
20 os.chdir(workdir)
21 try:
22 ip.runlines(cmd)
23 finally:
24 os.chdir(cwd)
25
26 ip.defalias("workdir",workdir_f)
27
28
29
30
31
General Comments 0
You need to be logged in to leave comments. Login now