Run a script on save in textmate











up vote
3
down vote

favorite
1












I was wondering if it was possible to run a custom script on save based on certain file names in textmate. For example I'd like to auto compile a C program sometime on save.










share|improve this question




























    up vote
    3
    down vote

    favorite
    1












    I was wondering if it was possible to run a custom script on save based on certain file names in textmate. For example I'd like to auto compile a C program sometime on save.










    share|improve this question


























      up vote
      3
      down vote

      favorite
      1









      up vote
      3
      down vote

      favorite
      1






      1





      I was wondering if it was possible to run a custom script on save based on certain file names in textmate. For example I'd like to auto compile a C program sometime on save.










      share|improve this question















      I was wondering if it was possible to run a custom script on save based on certain file names in textmate. For example I'd like to auto compile a C program sometime on save.







      textmate






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 19 '11 at 9:40









      studiohack

      11.3k1880113




      11.3k1880113










      asked Dec 21 '09 at 8:19







      Matt





























          3 Answers
          3






          active

          oldest

          votes

















          up vote
          4
          down vote













          It's actually fairly easy to do this using a custom command in a bundle.



          Here's how to make a simple command:




          • Open up the bundle editor, and find the bundle you want to add to.

          • Create a "New Command" using the button on the bottom left of the editor. Name it appropriately, and set its scope to source.c.

          • Set the action dropdown to "Key Equivalent", and set the shortcut Cmd + S.

          • Change the "Save" dropdown to "Current File".

          • Enter your command, and set the input and output dropdowns appropriately. Input will be piped to STDIN if I remember correctly.

          • Reload TextMate's bundles.


          That's it. You should now have a command which saves the file, and runs a command.



          You can probably do something with TextMate commands by using a macro in a similar way.






          share|improve this answer




























            up vote
            1
            down vote













            As far as I know, there's no way to do this as you described, for all save situations (i.e., using Command-S, selecting File->Save, etc.).



            You might be able to create a custom bundle item that saves the document and executes your script, and assign it Command-S, so that it runs when you use that keyboard shortcut.






            share|improve this answer




























              up vote
              0
              down vote













              you can trigger a command after save via callback.document.did-save semantic class. This works on TextMate2+






              share|improve this answer





















                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "3"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f86002%2frun-a-script-on-save-in-textmate%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown
























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                4
                down vote













                It's actually fairly easy to do this using a custom command in a bundle.



                Here's how to make a simple command:




                • Open up the bundle editor, and find the bundle you want to add to.

                • Create a "New Command" using the button on the bottom left of the editor. Name it appropriately, and set its scope to source.c.

                • Set the action dropdown to "Key Equivalent", and set the shortcut Cmd + S.

                • Change the "Save" dropdown to "Current File".

                • Enter your command, and set the input and output dropdowns appropriately. Input will be piped to STDIN if I remember correctly.

                • Reload TextMate's bundles.


                That's it. You should now have a command which saves the file, and runs a command.



                You can probably do something with TextMate commands by using a macro in a similar way.






                share|improve this answer

























                  up vote
                  4
                  down vote













                  It's actually fairly easy to do this using a custom command in a bundle.



                  Here's how to make a simple command:




                  • Open up the bundle editor, and find the bundle you want to add to.

                  • Create a "New Command" using the button on the bottom left of the editor. Name it appropriately, and set its scope to source.c.

                  • Set the action dropdown to "Key Equivalent", and set the shortcut Cmd + S.

                  • Change the "Save" dropdown to "Current File".

                  • Enter your command, and set the input and output dropdowns appropriately. Input will be piped to STDIN if I remember correctly.

                  • Reload TextMate's bundles.


                  That's it. You should now have a command which saves the file, and runs a command.



                  You can probably do something with TextMate commands by using a macro in a similar way.






                  share|improve this answer























                    up vote
                    4
                    down vote










                    up vote
                    4
                    down vote









                    It's actually fairly easy to do this using a custom command in a bundle.



                    Here's how to make a simple command:




                    • Open up the bundle editor, and find the bundle you want to add to.

                    • Create a "New Command" using the button on the bottom left of the editor. Name it appropriately, and set its scope to source.c.

                    • Set the action dropdown to "Key Equivalent", and set the shortcut Cmd + S.

                    • Change the "Save" dropdown to "Current File".

                    • Enter your command, and set the input and output dropdowns appropriately. Input will be piped to STDIN if I remember correctly.

                    • Reload TextMate's bundles.


                    That's it. You should now have a command which saves the file, and runs a command.



                    You can probably do something with TextMate commands by using a macro in a similar way.






                    share|improve this answer












                    It's actually fairly easy to do this using a custom command in a bundle.



                    Here's how to make a simple command:




                    • Open up the bundle editor, and find the bundle you want to add to.

                    • Create a "New Command" using the button on the bottom left of the editor. Name it appropriately, and set its scope to source.c.

                    • Set the action dropdown to "Key Equivalent", and set the shortcut Cmd + S.

                    • Change the "Save" dropdown to "Current File".

                    • Enter your command, and set the input and output dropdowns appropriately. Input will be piped to STDIN if I remember correctly.

                    • Reload TextMate's bundles.


                    That's it. You should now have a command which saves the file, and runs a command.



                    You can probably do something with TextMate commands by using a macro in a similar way.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jan 28 '10 at 17:42









                    Matt

                    1915




                    1915
























                        up vote
                        1
                        down vote













                        As far as I know, there's no way to do this as you described, for all save situations (i.e., using Command-S, selecting File->Save, etc.).



                        You might be able to create a custom bundle item that saves the document and executes your script, and assign it Command-S, so that it runs when you use that keyboard shortcut.






                        share|improve this answer

























                          up vote
                          1
                          down vote













                          As far as I know, there's no way to do this as you described, for all save situations (i.e., using Command-S, selecting File->Save, etc.).



                          You might be able to create a custom bundle item that saves the document and executes your script, and assign it Command-S, so that it runs when you use that keyboard shortcut.






                          share|improve this answer























                            up vote
                            1
                            down vote










                            up vote
                            1
                            down vote









                            As far as I know, there's no way to do this as you described, for all save situations (i.e., using Command-S, selecting File->Save, etc.).



                            You might be able to create a custom bundle item that saves the document and executes your script, and assign it Command-S, so that it runs when you use that keyboard shortcut.






                            share|improve this answer












                            As far as I know, there's no way to do this as you described, for all save situations (i.e., using Command-S, selecting File->Save, etc.).



                            You might be able to create a custom bundle item that saves the document and executes your script, and assign it Command-S, so that it runs when you use that keyboard shortcut.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Dec 27 '09 at 5:43









                            Lawrence Velázquez

                            929412




                            929412






















                                up vote
                                0
                                down vote













                                you can trigger a command after save via callback.document.did-save semantic class. This works on TextMate2+






                                share|improve this answer

























                                  up vote
                                  0
                                  down vote













                                  you can trigger a command after save via callback.document.did-save semantic class. This works on TextMate2+






                                  share|improve this answer























                                    up vote
                                    0
                                    down vote










                                    up vote
                                    0
                                    down vote









                                    you can trigger a command after save via callback.document.did-save semantic class. This works on TextMate2+






                                    share|improve this answer












                                    you can trigger a command after save via callback.document.did-save semantic class. This works on TextMate2+







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Nov 29 at 5:25









                                    vigo

                                    18126




                                    18126






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Super User!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.





                                        Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                        Please pay close attention to the following guidance:


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f86002%2frun-a-script-on-save-in-textmate%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Probability when a professor distributes a quiz and homework assignment to a class of n students.

                                        Aardman Animations

                                        Are they similar matrix