From 33b9551ce241bc1faac7875e6d026c2eb99790fb 2008-06-20 09:26:37 From: Ville M. Vainio Date: 2008-06-20 09:26:37 Subject: [PATCH] sh profile: ./foo runs 'foo' directly as system command --- diff --git a/IPython/Extensions/ipy_profile_sh.py b/IPython/Extensions/ipy_profile_sh.py index c25afef..ef4ae8e 100644 --- a/IPython/Extensions/ipy_profile_sh.py +++ b/IPython/Extensions/ipy_profile_sh.py @@ -117,6 +117,7 @@ def main(): # and the next best thing to real 'ls -F' ip.defalias('d','dir /w /og /on') + ip.set_hook('input_prefilter', dotslash_prefilter_f) extend_shell_behavior(ip) class LastArgFinder: @@ -138,9 +139,15 @@ class LastArgFinder: return parts[-1] return "" - - - +def dotslash_prefilter_f(self,line): + """ ./foo now runs foo as system command + + Removes the need for doing !./foo + """ + import IPython.genutils + if line.startswith("./"): + return "_ip.system(" + IPython.genutils.make_quoted_expr(line)+")" + raise ipapi.TryNext # XXX You do not need to understand the next function! # This should probably be moved out of profile diff --git a/docs/source/changes.txt b/docs/source/changes.txt index 85d3b83..d10ced7 100644 --- a/docs/source/changes.txt +++ b/docs/source/changes.txt @@ -29,6 +29,7 @@ New features Development Team" as the copyright holder. We give more details about exactly what this means in this file. All developer should read this and use the new banner in all IPython source code files. + * sh profile: ./foo runs foo as system command, no need to do !./foo anymore Bug fixes ---------