Show More
@@ -8,7 +8,7 b' compatibility)' | |||||
8 | """ |
|
8 | """ | |
9 |
|
9 | |||
10 | from IPython import ipapi |
|
10 | from IPython import ipapi | |
11 | import os,textwrap |
|
11 | import os,re,textwrap | |
12 |
|
12 | |||
13 | # The import below effectively obsoletes your old-style ipythonrc[.ini], |
|
13 | # The import below effectively obsoletes your old-style ipythonrc[.ini], | |
14 | # so consider yourself warned! |
|
14 | # so consider yourself warned! | |
@@ -129,7 +129,7 b' def main():' | |||||
129 | # and the next best thing to real 'ls -F' |
|
129 | # and the next best thing to real 'ls -F' | |
130 | ip.defalias('d','dir /w /og /on') |
|
130 | ip.defalias('d','dir /w /og /on') | |
131 |
|
131 | |||
132 |
ip.set_hook('input_prefilter', |
|
132 | ip.set_hook('input_prefilter', slash_prefilter_f) | |
133 | extend_shell_behavior(ip) |
|
133 | extend_shell_behavior(ip) | |
134 |
|
134 | |||
135 | class LastArgFinder: |
|
135 | class LastArgFinder: | |
@@ -151,13 +151,13 b' class LastArgFinder:' | |||||
151 | return parts[-1] |
|
151 | return parts[-1] | |
152 | return "" |
|
152 | return "" | |
153 |
|
153 | |||
154 |
def |
|
154 | def slash_prefilter_f(self,line): | |
155 |
""" ./foo now run |
|
155 | """ ./foo, ~/foo and /bin/foo now run foo as system command | |
156 |
|
156 | |||
157 | Removes the need for doing !./foo |
|
157 | Removes the need for doing !./foo, !~/foo or !/bin/foo | |
158 | """ |
|
158 | """ | |
159 | import IPython.genutils |
|
159 | import IPython.genutils | |
160 | if line.startswith("./"): |
|
160 | if re.match('(?:[.~]|/[a-zA-Z_0-9]+)/', line): | |
161 | return "_ip.system(" + IPython.genutils.make_quoted_expr(line)+")" |
|
161 | return "_ip.system(" + IPython.genutils.make_quoted_expr(line)+")" | |
162 | raise ipapi.TryNext |
|
162 | raise ipapi.TryNext | |
163 |
|
163 |
General Comments 0
You need to be logged in to leave comments.
Login now