Skip to content

Instantly share code, notes, and snippets.

@Sorseg
Created February 27, 2016 12:45
Show Gist options
  • Save Sorseg/6414e8c7475c093253e7 to your computer and use it in GitHub Desktop.
Save Sorseg/6414e8c7475c093253e7 to your computer and use it in GitHub Desktop.
import os
def cat(f):
return open(f).read()
def ls():
return os.listdir('.')
def pwd():
return os.getcwd()
def cd(d):
os.chdir(d)
cmds = {
'ls': ls,
'pwd': pwd,
'cd': cd,
'cat': cat
}
def msh():
while True:
user_input = input('{}: '.format(pwd()))
cmd, *params = user_input.split(' ')
if cmd in ['exit', 'quit', 'q']:
break
result = cmds[cmd](*params)
if result:
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment