Sublime Forum

Run scripts from sidebar context-menu

#1

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.

0 Likes

#2

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)

0 Likes

#3

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…

0 Likes

#4

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

0 Likes

Dynamic menu items
#5

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?

0 Likes

Extending SideBar, questions, suggestions
#6

What OS are you using? It’s working for me on 2132.

0 Likes

#7

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

In v2126 on OSX 10.7, it seems to work fine.

0 Likes

#8

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?

0 Likes