1

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

Sebastian Zeki
  • 6,690
  • 11
  • 60
  • 125
  • If you have TextMate1, you can manage your bundle's grouping etc.. I'm organizing my bundle's cosmetic via TextMate1 :) If you don't have, you need to follow up steps shown as answer bellow... – vigo Mar 21 '16 at 06:50

1 Answers1

5

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.

Graham P Heath
  • 7,009
  • 3
  • 31
  • 45
  • Thanks so much for the really detailed answer. Its really appreciated. Unfortunately I fail at step 1. It doesn't open in Xcode. When I try and open it directly an error says 'The bundle "Shell Script" could not be installed because it is in delta format- Contact the author of this bundle to get a properly exported version – Sebastian Zeki Jan 14 '15 at 19:40
  • Sounds like you're opening the bundle with Xcode; right click on the bundle and go to "Show Contents", then double click the info.plist. – Graham P Heath Jan 14 '15 at 20:23
  • OK. Great seems to work. But a hell of a job. Surely textmate need to sort this. I've written an email and will let you know the response – Sebastian Zeki Jan 14 '15 at 22:07
  • This was the reply from textmate so for the sake of simplicity I'm going to wait for the update: "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 your really interested. If you can put the bundle on Github or somewhere else to download and tell me how you want the menu laid out I can do it for you." – Sebastian Zeki Jan 15 '15 at 11:16
  • I'd take the man up on his generous offer! The support that I receive (and give) from the mailing list is no small part of my love for this software. – Graham P Heath Jan 15 '15 at 16:23
  • Thanks so much. This worked perfectly. One question: how to add a separator line? – magicrebirth Jan 31 '16 at 22:40