Home Download Buy Blog Forum Support

run scripts from sidebar context-menu

run scripts from sidebar context-menu

Postby atomi on Tue Jun 28, 2011 7:46 am

This is probably a long shot(?).
I'd like to run shell scripts on various files and folders by right clicking them on the sidebar file tree.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: run scripts from sidebar context-menu

Postby jps on Tue Jun 28, 2011 8:15 am

You can add entries to that context menu, and have them call a plugin which then runs your shell script.

For an example, take a look at the Diff package (it adds a 'Diff Files' entry to the context menu when you select two files within an open folder)
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: run scripts from sidebar context-menu

Postby jbjornson on Tue Jun 28, 2011 8:45 am

jps wrote:it adds a 'Diff Files' entry to the context menu when you select two files within an open folder


Very cool feature that I had no idea existed. One thing I noticed is that the "Diff files..." option is only available if you select two files from open folders in the "Folders" area of the sidebar, but not if you select two files in the "Files" area of the sidebar. Would it be possible to enable diffing files in the "Files" area of the sidebar as well?

Another question is what magic is being used to only show the menu option when exactly two files are selected? There are no hints in "Side Bar.sublime-menu" that suggest how this might be done...
jbjornson
 
Posts: 353
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: run scripts from sidebar context-menu

Postby jps on Tue Jun 28, 2011 8:55 am

jbjornson wrote:Another question is what magic is being used to only show the menu option when exactly two files are selected? There are no hints in "Side Bar.sublime-menu" that suggest how this might be done...


This is done by DiffFilesCommand.is_visible(), in diff.py

Customising the context menu for files is still on the todo list - it's hard coded atm
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: run scripts from sidebar context-menu

Postby teejae on Fri Oct 14, 2011 11:40 am

jps,
I am trying to run the diff command, in v2126, and it seems like there is a bug:

DiffFilesCommand.is_visible consistently only gets 1 file in the files parameter.

I have printed the files list, and it only has the last selected file. Sounds like a bug?
teejae
 
Posts: 16
Joined: Tue Oct 11, 2011 5:38 pm

Re: run scripts from sidebar context-menu

Postby jps on Fri Oct 14, 2011 11:59 am

What OS are you using? It's working for me on 2132.
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: run scripts from sidebar context-menu

Postby teejae on Fri Oct 14, 2011 4:25 pm

I was testing on v2126 on Ubuntu 10.04, where this was failing.

In v2126 on OSX 10.7, it seems to work fine.
teejae
 
Posts: 16
Joined: Tue Oct 11, 2011 5:38 pm

Re: run scripts from sidebar context-menu

Postby teejae on Tue Oct 18, 2011 2:45 am

Ok, with both v2126 and v2132, I've confirmed this on OSX 10.6 Snow Leopard and Ubuntu 10.04. There is only a single file being passed to the Diff function even though 2 files are selected.

The behavior does work correctly on OSX 10.7. Any ideas?
teejae
 
Posts: 16
Joined: Tue Oct 11, 2011 5:38 pm


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: Exabot [Bot] and 4 guests