Terry's leoscreen stuff could be a good starting point
It's not the same as a terminal which follows the path of the active
node, but adding a "command shell here" button is a useful facsimile:
http://groups.google.com/group/leo-editor/browse_thread/thread/dd063fbdbc073b44?fwc=1&pli=1
though you'll need to change the Popen line to do the right thing on linux.
--
-matt
I added the recipe to the wiki, http://leo.zwiki.org/CommandShellHere,
and spent some time trying to decuce the linux equivalent. No luck.
From here[1] I would expect something like the below to work but all I
get is `OSError: [Errno 2] No such file or directory`
Popen(r'/bin/bash --login -c "pushd %s;bash"' % path)
--
-matt
> Popen(r'/bin/bash --login -c "pushd %s;bash"' % path)
Close. Maybe
Popen(['xterm', '-e', '/bin/bash', '--login', '-c', 'pushd %s; bash'%path])
Neat use of pushd. If you're running screen, a shell switching
wrapper for unix, you can do use code like that in the leoscreen plugin
to push commands into existing terminals, another option.
Cheers -Terry
> Popen(['xterm', '-e', '/bin/bash', '--login', '-c', 'pushd %s; bash'%path])
>
> Neat use of pushd.
Ok, that kept nagging at me, trying to work out why pushd was working -
I don't think it needs to be pushd, cd would work, the bask invoked
from within the first bash is just inheriting the current directory of
the first bash.
Also, /bin/sh should be a link to the users shell of choice, which
might not be bash. dash is the new default for Ubuntu, although I
always have to set it back to bash for some of my scripts.
Cheers -Terry
ok, that led to a more fruitful path {heheh}, this works:
Popen(['xterm', '-e', '/bin/bash'], cwd=path)
I leaned of the `cwd` parameter from
http://www.python.org/dev/peps/pep-0324/. There talk in there of
`shell=True` also which might be appropriate here, but it's
accompanied by dire warnings of security troubles so I didn't play
with it.
Thanks for the xterm idea. It's always annoyed me that the "shell
here" had to use the same console which started Leo. I changed xterm
to gnome-terminal on Ubuntu, and more iterations led to the short and
sweet:
Popen('gnome-terminal', cwd=path)
I tried using just `/bin/sh` so the button would not depend on the
flavour of linux, but that opens a shell with no feedback for current
working directory etc.
-----
And here's how to do the same thing for Windows:
Popen('cmd.exe /c "start cmd.exe"', cwd=path)
The first cmd starts, opens a new cmd shell in a new window, then
closes ("/c"). This trickery is needed because "start" is a builtin
resident command of the shell (cmd.exe).
...time passes...it turns out the below appears to be functionally
equivalent. I personally can't see how this is less secure than the
previous, so it's what I'll use now. The "shell from Leo" is optional,
so I can tell from the window title that this particular shell will
have python etc. active (my default shell does not).
Popen('start "Shell from Leo" cmd.exe', cwd=path, shell=True)
cheers,
-matt