Sublime Forum

Add ability to search and create files in Sublime using Alfred or some other means

#1

deanishe developed an awesome Alfred workflow that lets you quickly open sublime text projects and besides when sublime text decides to open the project as json (consider that a bump to try to figure out why that happens :slight_smile: ) the workflow works really well.

I submitted a feature request to add the ability to quickly search/create files/directories from the Alfred search bar using a syntax and format that could be similar to the Sublime-AdvancedNewFile plugin. However, as can be seen in the feature request link, deanishe responded that it’s not possible to do this kind of thing from outside of alfred.

I don’t know because I haven’t learned about it yet, but isn’t this a textbook opportunity for bash scripting (or some other type of scripting)? My understanding of bash scripting is that it basically lets us glue together programs. To me (maybe because I don’t know about bash/python/ruby/applescript automation scripting yet) this seems like an even more textbook case because Alfred is a program that is literally built to run bash scripts and sublime is literally built to run python scripts.

So if I learn to about bash scripting in a *nix environment will I be able to write a script that does things like:

  • tell sublime to run a command or link multiple commands together to do things like:
  • create a file
  • toggle the side bar
  • toggle a directory in the sidebar
  • get information from sublime piped backwards about things like:
  • what directories exist
  • what files exist

Maybe what I could do is learn about bash scripting and write a script that does all the directory crawling and file creation independent of sublime and then just tell sublime to open the project afterwards but I’d still like to figure out how to tell sublime to “open this file and display the sidebar in this specific configuration”

As a side note I’m brainstorming about ways I could set all this up so sublime text doesn’t open a new project window when I start searching/creating files from outside of sublime. This is also something that I’ve read is not possible but I’m thinking it just has to be (once again maybe just naive about scripting), because even if I can’t tell sublime to update it’s view in a specific way from the outside (which I’m still not completely convinced you can’t do) couldn’t another textbook script do something like:

  1. Search for and close the sublime window associated with a specific project
  2. Reopen the project with a different view

So my main questions are: am I on the right track with trying to learn about bash scripting to hopefully accomplish the goal of: making a snappy way to search/create files within a sublime project (or just a regular directory) and then open up a custom view in sublime? Should I be learning about python scripting instead? What are some resources you would recommend to help me get more educated about how I can solve these problems?

0 Likes