Sebastian Zeki
Sebastian Zeki

Reputation: 6874

how to group snippets in textmate

I have got a nice bunch of shell scripting snippets that I'd like to categorise (file manipulation tools, networking scripts etc.) I can only add scripts but not group them together (so I can hover over a group called for eg Networking and a submenu then lists my snippets. Does anyone know how to do this? I thik this would be really helpful given how many snippets I have

Upvotes: 1

Views: 568

Answers (1)

Graham P Heath
Graham P Heath

Reputation: 7399

Perhaps the first question is should you? Read this disclaimer from the mailing list and decide for yourself.

This is currently not possible in the bundle editor it has to be done manually. It will be added as we revise the bundle editor shortly. Since it’s going to be added it’s not really worth describing how to do it manually unless you're really interested. [as of Jan-2015]

If you really are interested, keep reading:

First back up your bundle. Then using XCode's plist editor, open your bundle's info.plist.

Your bundle is located here: ~/Library/Application Support/Avian/Bundles/[Bundle Name]/

So your info.plist is located here: ~/Library/Application Support/Avian/Bundles/[Bundle Name]/info.plist

In the info.plist: Create this structure if you don't already have it.

steps 1 through 3

  1. Right click -> Add Row -> "mainMenu".

  2. Change "mainMenu"'s type to Dictionary.

  3. Create nested items "submenus", "items", and "excludedItems", changing "submenus"'s type to "Dictionary" and "items" & "excludedItems" to Array.

  4. Open Terminal.app and run the command uuidgen

  5. Copy the output. (from now on called [UUID#1])

  6. Create a new item under "submenus", naming it by pasting [UUID#1]

  7. Change [UUID#1]'s type to Dictionary.

  8. Add a child to [UUID#1] named "name", set its value to "Network Scripts" (or whatever)

  9. Add a child to [UUID#1] named "items", set its type to Array

  10. Add items using the (+) button, each item is a UUID from your commands. To get this UUID, open the command's file in TextMate. If you try to Open the .tmCommand file directly TextMate will complain, "The bundle item [Bundle Item]; is already installed".

    a) You can simply open the Commands folder, and TextMate won't mind opening the files from the file drawer.

    or

    b) or `mate ~/Library/Application Support/Avian/Bundles/[Your Bundle]/Commands/[Your Command].

  11. When the file is open find these lines. You're string will be different but formatted the same.

    <key>uuid</key>
    <string>8E9BA0D3-E282-4516-8565-E920EA98C898</string>
    

    This is the UUID for your command. Now known as [UUID#2]

  12. Go back to the info.plist, in step 9 you created a "items" array, add [UUID#2] to the array. Repeat 10 - 12 to add multiple items.

  13. Now all you have to do is add your new sub menu to your 'mainMenu.items', simply add [UUID#1] to the array. (This final missing step thanks to the mailing list, thread "How to move, order or group bundle items in a TextMate 2 Bundle?", thanks Nigel!)

For me; the changes were reflected without a restart.

Do be sure to save your .plist file between modifications.

Once complete back up or commit the plist, you wouldn't want to lose it incase of something terrible happening.

Upvotes: 5

Related Questions