| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #!/usr/bin/env python
- import sys
- import os
- import readline
- import subprocess
- from plumbum import local
- def vi():
- subprocess.call('vi')
- def ll(*args):
- print local['ls']['-la']()
- # is a builtin
- def cd(*args):
- # TODO: no param, go to home
- # param is - : go back
- print args
- if len(args) == 0:
- args = '/home/woelper'
- else:
- args = args[0]
- print 'cd to', args[0]
- local.cwd.chdir(args[0])
- def exec_if_builtin(string):
- print 'STR', string
- string = string.split()
- command = string[0]
- parameters = string[1:]
- possibles = globals().copy()
- possibles.update(locals())
- method = possibles.get(command)
- if method:
- method(parameters)
- return True
- print 'Did not detect a function by that name'
- def as_plumbum(string):
- print 'Running cmd through plumbum'
- # TODO: until pipe or special char
- # split the string
- string = string.split()
- #print string
- command = string[0]
- parameters = string[1:]
- print command, parameters
- print local[command][parameters]()
- # line for line
- while True:
-
-
- """
-
- input_string = raw_input(local.cwd + ' >> ')
-
- # was the string a regular line of python?
- if exec_if_builtin(input_string) is not True:
- try:
- exec(input_string)
- except:
- try:
- as_plumbum(input_string)
- except:
- print 'command not found:', input_string
- """
|