import os def wrap(f): """ Wraps a function so that if it's entered *by itself* in the interpreter without ()'s, it gets called anyway """ class W: def __init__(self, f): self.f = f def __repr__(self): x =apply(self.f) if x: return repr(x) else: return '' return W(f) def ls(): """ Produces a directory listing of the current directory. Usage: ls """ os.system('ls -Fs') return None ls = wrap(ls) def lsd(directory): """ Produces a directory listing of the given directory. Usage: lsd(directory) """ os.system('ls -Fs '+directory) return None def ll(): """ Produces a "ls -ltr" directory listing of the current directory. Usage: ll """ os.system('ls -ltr') return None ll = wrap(ll) def pwd(): """ Changes the working python directory for the interpreter. Usage: pwd (no parens needed) """ return os.getcwd() pwd = wrap(pwd) def cd (directory): """ Changes the working python directory for the interpreter. Usage: cd(directory) where 'directory' is a string """ os.chdir(directory) return def cat(file): """ call the unix cat command with file as the argument Usage: cat(filename) """ os.system('cat '+file) return None def emacs(file=""): """ open file in Emacs """ os.system("emacs -nw " + file) return None def less(file): os.system("less "+file) return None def rm(file): os.system("rm "+file) return None def rmdir(directory): os.system("rm -rf " + directory) return None def gv(file): os.system("gv "+file) return None def acroread(file): os.system("acroread "+file) return None def eog(file): os.system("eog "+file) return None