How to setup iPython as a simplified command shell for the average user

Viewed 532

Summary: Is it possible to setup iPython to look like a basic dos/bash command line terminal to the average user (cd, ls, mkdir, rm... etc) , and then expose a few extra proprietary commands?

In Depth: I work for a video game company where the users have never experienced a "good" CLI in a production pipeline. So in response i've been working for some time writing a CLI using cmd.py in python, recreating commonly used dos commands and then augmenting them with my own custom commands to do various things, ex: jump quickly across pre-defined production folders, simplified perforce management commands, find/import files with recursive ant-glob patterns into our authoring tool... etc etc...

In the middle of the process i stumbled upon ipython. I'm not very familiar with it but i already feel it's what i should be using, as it does a lot of what i want for free. It handle's ansi colors perfectly. All shell commands are available via "!", can use "|,>,<" and all built in shell functions for free, the benefits go on and on...

The one caveat is that my targeted audience is easily intimidated by CLI's... and so when they type "more textfile.txt" as an input, they expect the default dos behavior of printing the contents of the file, and not:

In [42]: more textfile.txt
  File "<ipython-input-42-e442b4ca857b>", line 1
    more file.txt
            ^
SyntaxError: invalid syntax

Of course, "!more textfile.txt" would do what they expect, but i don't want them to have to type "!" for essentially 95% of the commands they would use.

So i'm looking for a way to launch ipython in a completely simplified manner where in my ideal (fantasy perhaps) world:

  • All the shell commands (cd, ls/dir, mkdir, more, rm/del, etc...) would be accessible at the forefront without any "!"
  • All python commands (import, def, class, for, print, while, etc...) would be inaccessible, except from a predefined few proprietary commands to do various pipeline operations, maybe leave basic arithmetic commands accessible?

And as a bonus: a way to alternate between default ipython and the very restrained and simplified command shell replacement version i'm dreaming about... ex: typing "normal" would restore all of ipython's default behavior... and typing "cli" would go back to the simplified version.

Final note: What i'm looking for is likely a fool's errand and i should probably stick with launching python.exe in a command shell with my own clumsy CLI script and call it a day... But I figured that if what i'd like iPython to do here is remotely possible, Stackoverflow is where i'd get the answer quickly :)

2 Answers
Related