Maybe a stupid question?

36 views
Skip to first unread message

HEK

unread,
Sep 30, 2010, 3:50:46 AM9/30/10
to DreamPie
Hi,

I just started using Dreampie and i find it awesome.
But there is a small question that i have and i coudn't find any
answer:
What is the equivalent of ipython access to the system shell via the !
prefix.
A very typical usage is to change dir to a specific directory.

ps: Obviously, i don't want to use the os and os.path modules

best regards

Hek

Noam Yorav-Raphael

unread,
Oct 2, 2010, 5:51:58 PM10/2/10
to drea...@googlegroups.com
Hello,

There's no built-in way to do so. However, you can use DreamPie's
features to have it.

Create a file called init.py somewhere on your PYTHONPATH, with this:
==================
__all__ = ['sh', 'cd']

import os
import subprocess

def expects_str(f):
f.__expects_str__ = True
return f

@expects_str
def sh(s):
return subprocess.call(s, shell=True)

@expects_str
def cd(path):
r = os.chdir(os.path.expanduser(path))
if r != 0:
return r
================

Now, in the preferences dialog, in the shell tab, write this command
to be executed on startup:

from init import *

Now, to run shell commands, type "sh <your command>", for example, "sh
ls" (you'll get 'sh("ls")' written), and press ctrl-enter. To change
directories, type "cd dir".

I hope to add a basic "init file" like this to the next version of
DreamPie, so it will be easier to set up this behavior.

I hope this helps,
Noam

Amin Abbaspour

unread,
Oct 3, 2010, 2:28:56 AM10/3/10
to drea...@googlegroups.com
Hi,

As Hek suggested, I'll be great to see iPython like shell integration
in DreamPie. It's a helpful and frequently used feature.

Regards,
Amin

Noam Yorav-Raphael

unread,
Oct 3, 2010, 5:06:12 AM10/3/10
to drea...@googlegroups.com
I agree. The only thing is that I don't really like adding extra syntax.

I think that type "sh command"(ctrl-enter) is nearly as easy as typing
"!command" (enter). Don't you think so?

Noam

Reply all
Reply to author
Forward
0 new messages