open Command Prompt here

6 views
Skip to first unread message

Matt Wilkie

unread,
May 27, 2010, 6:20:36 PM5/27/10
to leo-e...@googlegroups.com
Hello world,

Here is handy little button for windows users. Create node with the
headline "@button CMD here", save and reopen Leo.

QQQ
@
Open a windows cmd.exe prompt in the path of the currently selected node.
A mapped drive letter will be created for a UNC path.

Adapted from:
http://webpages.charter.net/edreamleo/scripting.html#working-with-directives-and-paths
http://www.mail-archive.com/leo-e...@googlegroups.com/msg12177.html
@c

d = c.scanAllDirectives(p)
# g.es(g.dictToString(d)) #uncomment to show results of above in log pane

path = d.get('path')
name = p.anyAtFileNodeName()
if name:
name = g.os_path_finalize_join(path,name)
g.es(name)

from subprocess import Popen
Popen(r'cmd.exe /k pushd %s' % path)

QQQ

enjoy :)

-matt

Matt Wilkie

unread,
May 27, 2010, 6:22:44 PM5/27/10
to leo-e...@googlegroups.com
Ideas for improvement:

- Generalize for other environments, sh on Linux, (zsh on Mac?)
- add a keyboard shortcut so you don't have to mouse.

-matt

Terry Brown

unread,
May 27, 2010, 11:36:10 PM5/27/10
to leo-e...@googlegroups.com
On Thu, 27 May 2010 15:20:36 -0700
Matt Wilkie <map...@gmail.com> wrote:

> d = c.scanAllDirectives(p)
> # g.es(g.dictToString(d)) #uncomment to show results of above in log pane
>
> path = d.get('path')

I think you can use 'path = c.getNodePath(p)' here, although I see active_path.py is doing something similar to what you do, one of those don't touch it if it works things.

Cheers -Terry

Reply all
Reply to author
Forward
0 new messages