From c1bbcb3dceefb0b3581b1a4dbd70ab54f3d1f706 2007-09-05 19:25:39 From: vivainio Date: 2007-09-05 19:25:39 Subject: [PATCH] sh profile uses 'cygwin in path' to determine ls --color=auto alias and whether to load ipy_fsops.py --- diff --git a/IPython/Extensions/ipy_profile_sh.py b/IPython/Extensions/ipy_profile_sh.py index 6c5f29c..06c7f9d 100644 --- a/IPython/Extensions/ipy_profile_sh.py +++ b/IPython/Extensions/ipy_profile_sh.py @@ -36,7 +36,6 @@ def main(): import ipy_rehashdir import ipy_signals - ip.ex('import os') ip.ex("def up(): os.chdir('..')") @@ -52,14 +51,10 @@ def main(): # I like my banner minimal. o.banner = "IPython %s [on Py %s]\n" % (Release.version,sys.version.split(None,1)[0]) - # make 'd' an alias for ls -F - - # ip.magic('alias d ls -F --color=auto') ip.IP.default_option('cd','-q') - # If you only rarely want to execute the things you %edit... - + # If you only rarely want to execute the things you %edit... #ip.IP.default_option('edit','-x') @@ -83,7 +78,7 @@ def main(): ip.magic('rehashx') syscmds = db.get("syscmdlist") - # locase aliases on win#2 only + # lowcase aliases on win32 only if os.name == 'posix': mapper = lambda s:s else: @@ -96,11 +91,20 @@ def main(): if key not in ip.IP.alias_table: ip.defalias(key, cmd) - if 'ls' in syscmds: - # use the colors of cygwin ls (recommended) - ip.magic('alias d ls -F --color=auto') # mglob combines 'find', recursion, exclusion... '%mglob?' to learn more ip.load("IPython.external.mglob") + + # win32 is crippled w/o cygwin, try to help it a little bit + if sys.platform == 'win32': + if 'cygwin' in os.environ['PATH'].lower(): + # use the colors of cygwin ls (recommended) + ip.defalias('d', 'ls -F --color=auto') + else: + # get icp, imv, imkdir, igrep, irm,... + ip.load('ipy_fsops') + + # and the next best thing to real 'ls -F' + ip.defalias('d','dir /w /og /on') extend_shell_behavior(ip) diff --git a/doc/ChangeLog b/doc/ChangeLog index 2e6c84b..7854739 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -4,12 +4,16 @@ of ['dirname/foo','dirname/bar', ...]. * Extensions/ipy_fsops.py: added, has usefull shell utils for plain - win32 installations: icp, imv, imkdir, igrep, collect (collect + win32 installations: icp, imv, imkdir, igrep, irm, collect (collect is useful for others as well). * iplib.py: on callable aliases (as opposed to old style aliases), do var_expand() immediately, and use make_quoted_expr instead of hardcoded r""" + + * Extensions/ipy_profile_sh.py: Try to detect cygwin on win32, + if not available load ipy_fsops.py for cp, mv, etc. replacements + 2007-09-04 Ville Vainio