Dedicated Snippets folder and scripts for snippet management#14
Dedicated Snippets folder and scripts for snippet management#14petrowsky wants to merge 5 commits intoDanShockley:masterfrom
Conversation
|
Oh, and also added some example scripts. If you didn't want to include sample scripts you could simply put a README within the Snippets folder providing instructions about how to use the folder. Suggested subfolders for anyone who wants to use these scripts would be
|
|
Matt, I like the Snippets folder idea, and thank you for switching over some of the dialogs to use notifications. |
|
This is really well done! I tend to think this repo should avoid become a repository of blessed snippets because reconciling everyone's opinions sounds difficult. Including some sample snippets is smart, but as someone with my own large library of snippets already, I'd prefer to see any included snippets treated as examples rather than "official". I like the idea of creating a config file somewhere and potentially even an AppleScript to open that config file in Finder and/or a default code editor. I should also add for transparency, that I probably won't personally use the |
|
I only added the few example scripts so it would showcase just one of the many methods of Snippet organization. I would personally just add the Snippets folder itself and included a README.md file with information about the various methods of snippet organization. Leave the Snippets folder empty for the end user to choose how they want to organize/manage things. Here are just a few of the possible ways.
Essentially, the goal would be a single location which is easy to open. If the end user chooses to enable the Script menu in the menu bar then a simple script to open this folder is effective in getting the end user to their starting point. Whether managing their own personal flat list or managing a folder hierarchy of multiple git submodules. I would not use the /Application Support folder as this is typically reserved for applications to use since it is behind the hidden ~/Library folder. All you need is a dedicated folder and then let the user decide how they want to use it. I agree with @jwillinghalpern in that it should not be a repo of snippets. That was not my intention. I only included the examples to give you a taste of what would be possible. There are MANY various tools in which snippets can be loaded onto the clipboard. I personally use BetterTouchTool and LaunchBar. But I'm aware of the original Quicksilver, Raycast, Alfred, TypeIt4Me, Typinator and others. Create a branch and merge in the pull. Get rid of the example scripts and put a link into a README.md within Snippets pointing the user to possible snippet repos and info about organization options. Ultimately, you just need a way for the user to open a singular location and a way to load things from that location. |
|
So, since I might want to start using the Snippets folder myself, while still being able to push my changes to the project, I'm thinking I will do the following:
For the config file idea, which we wouldn't yet need for the above, I'm considering the following:
I like the idea of having customizable settings, especially since some of the scripts currently have internal properties that can be switched on or off, and users might want, for example, to re-enable the automatic "prettification" of XML, as long as they are aware of the downsides/risks involved. Either of you have any suggested changes to the above two courses of action? Anyone else? |
If you make a 'working' branch, then you can merge the pull into that branch and make the changes you want. Then you can merge that into your master branch. But that's just one way of doing things. You're the repo owner so you can do what you want with the pull.
I would ask why? Why create code just to create a folder when it can already be part of your code structure. You can even just merge the existing pull and then just delete the examples and create the README within Snippets. It's just another commit and if anyone was ever interested they can read the commit log.
If you're going to treat a folder named Snippets as your starting point for entry into managing one or multiple sources of snippet code, then why ignore it. As part of your code structure you're simply saying "This code references a folder named Snippets. Anything you put in there will be accessible once the Snippets folder is opened." This is no different than any other repository which chooses to use src, dist, build, etc. It's simply the choice of a name of a folder which your code references or stores things.
Yep. People always like documentation about how things work.
Personally, you're simply providing some executable code which is not super complex. Adding a config setup seems a bit much unless your AppleScripts are going to reference that config. And...if you are going to use a config file, then the natural choice would seem to be a .plist as AppleScript is an Apple technology. Using something like a plain .txt, .json or .yml would require translation. Where you can likely directly access the config settings using a .plist. Here's some sample code |
|
On the Snippets folder: On having a config file: For both of these, I'm wondering if there is a way of using git that makes my concerns moot. If so, can you point me in the right direction? |
|
Probably a communication/wording issue. You said "Add the Snippets folder to the .gitignore file", in which adding So, I would suggest committing the folder Snippets and one included file named README.md to your repo. You would then add When you say "Add the Snippets folder to .gitignore...", that is different than saying ignore the contents of the Snippets folder. The Snippets folder would be your root starting point for all snippets. In my personal use case, I will be using git submodules to point to multiple external repositories of snippets, plus including my own collection in that root. It currently looks like this. |
|
Ha! Thank you, Matt. I actually hadn't realized that the .gitignore would support a wildcard like that, but of course it would. That makes a lot of sense. I'll do that. I'll also do the config.plist, if/when I find a few places in the various scripts where a user might want to customize default behaviors. |
|
Can I get some eyes on this and get a merge. If not, then just let me know and I'll maintain my own fork and close this merge request. The only things happening, other than the added two AppleScripts used for folder interaction, and the Snippets folder being updated in .gitignore, is the one remaining revision to Scripts/fmClip - Clipboard XML to FM Objects.applescript where I had updated the dialog to an OS notification. If you don't want the updates using Notifications instead of dialogs then let me know and I'll revert that in my branch and you can merge this in with it's innocuous use of an empty Snippets folder (where I will personally be using git submodules to manage my own snippet collections). If you don't want to identify the Snippets folder as a convenience to end users, then let me know and I'll close this request or you can close it yourself as an indication that you don't want to suggest a dedicated Snippets folder for end-user managed snippets. |
|
Update: I plan to make the changes Matt recommended next week. Hopefully my schedule will be agreeable. Thanks for the advice and the proposed changes, Matt! |
Added two AppleScripts which allow for managing a library of Snippets within a dedicated Snippets folder. One script opens the folder for management within the OS and the other simply presents a file chooser and copies the contents to the clipboard and converts to FM Objects.
If the changes to using notification center over dialogs is undesirable you can revert those. Or, I can make a new patch.