Jump to content
phyllisstein

Sublime Text Projects

Recommended Posts

Functionality for this workflow has been folded into "Open in Sublime." Just enter the keyword "subl" to be given the option of opening the frontmost Finder window's items in Sublime or opening a recent project. The keyword "sub*" allows you to search all your files for a particular one to send to Sublime, and the "Open in Sublime" file action does precisely what you'd expect. The version of ST that you're using is automatically detected, with preference given to ST3 (way of the future and all).

 

Download Here

Edited by phyllisstein

Share this post


Link to post

Not working for me, when I select it it doesn't update or list any of the projects available for quickopen.

 

Also the key set in your download is just "p"

Share this post


Link to post

Not working for me, when I select it it doesn't update or list any of the projects available for quickopen.

 

Also the key set in your download is just "p"

 

Are you on ST2 or ST3? Wanna shoot me an e-mail at d at daniel dot sh and I'll walk you through some debugging? I'd be super-grateful.

Share this post


Link to post

This is great! What are your thoughts on merging your Sublime Text workflows?

 

So "subl" would show options to open the current finder path in Sublime, and show a list of recent projects?

 

Would be neat to access Sublime through one keyword.

 

Thanks for the great work with all your workflows!

Share this post


Link to post

This is great! What are your thoughts on merging your Sublime Text workflows?

 

So "subl" would show options to open the current finder path in Sublime, and show a list of recent projects?

 

Would be neat to access Sublime through one keyword.

 

Thanks for the great work with all your workflows!

Done and done. I've been doing housekeeping all afternoon, so I just made a few quick changes and it's set. See the first post in this thread for a new download link.

Share this post


Link to post

Thanks for the great workflow. I just extended it to have a hotkey (mine is Cmd + Shift + E) to open the currently selected file in Sublime Text. It's significantly useful for me as I usually browse Finder for files in projects.

Share this post


Link to post

Can't get this to find my projects for some reason and threw the feedback.log command on the script filter. Any ideas from this output?

 

Traceback (most recent call last):
  File "proj.py", line 52, in <module>
    find_projects()
  File "proj.py", line 24, in find_projects
    projects = json.load(f)["workspaces"]["recent_workspaces"]
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 278, in load
    **kw)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 326, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 382, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Invalid control character at: line 51 column 13 (char 863) 
  

subl just hangs on Working... I get the open Open Finder Selection but the rest just "is Working..."

 

Thank you, sorry to be a pain in the ass

Edited by twinpeaks

Share this post


Link to post

Can't get this to find my projects for some reason and threw the feedback.log command on the script filter. Any ideas from this output?

 

Traceback (most recent call last):
  File "proj.py", line 52, in <module>
    find_projects()
  File "proj.py", line 24, in find_projects
    projects = json.load(f)["workspaces"]["recent_workspaces"]
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 278, in load
    **kw)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 326, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 382, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Invalid control character at: line 51 column 13 (char 863) 
  

subl just hangs on Working... I get the open Open Finder Selection but the rest just "is Working..."

 

Thank you, sorry to be a pain in the ass

No pain at all. Are you using ST2, or ST3? The last time this problem cropped up it was because somebody's Package Control installation had inserted some character that caused the notoriously finnicky JSON loader to choke. The guy solved it by deleting every occurrence of that character, but I still don't know what it was. It'd be most helpful if you could e-mail me (d at daniel dot sh) your Session.sublime-session file, so that I could fix this permanently; otherwise, delete the character it's complaining about and you'll be fine. The file is in ~/Library/Application Support/Sublime Text 3/Local/ or ~/Library/Application Support/Sublime Text 2/Settings/.

 

The path thing isn't there anymore because I doubted that it was useful and rearranged the workflow; I could probably find a way to put it back if you wish.

Share this post


Link to post

I just pushed an update that should address the "Invalid control character" thing. Autocomplete entries in the file often included tabs, which the JSON decoder didn't like. Figured it out once it started breaking on my own machine. Give the new version a shot; it should be accessible through the download link above or Alleyoop.

Share this post


Link to post

Done and done. I've been doing housekeeping all afternoon, so I just made a few quick changes and it's set. See the first post in this thread for a new download link.

 

Awesome! Thanks mate, great stuff ;-)

Share this post


Link to post

Alfred: 2.0.5

Sublime Text: 3 3048

 

When opening a project, can't restore all the tabs.

 

Tried to modify proj.py L32 `projPath = os.path.join(projPath, projTitle + ".sublime-project")` to `projPath = os.path.join(projPath, projTitle + ".sublime-workspace")`, still not working.

Share this post


Link to post

Alfred: 2.0.5

Sublime Text: 3 3048

 

When opening a project, can't restore all the tabs.

 

Tried to modify proj.py L32 `projPath = os.path.join(projPath, projTitle + ".sublime-project")` to `projPath = os.path.join(projPath, projTitle + ".sublime-workspace")`, still not working.

 

I'm afraid that's an issue with Sublime. It also doesn't restore open tabs, as far as I know, if you simply double-click the .sublime-project file on your hard drive. Opening the .sublime-workspace file would work—something that I wasn't aware of till just now!—but the subl command doesn't know how to deal with workspaces and they're not bound to open with Sublime in OS X. You'd have to take either of the latter issues up with jps, I think.

 

 

It would be nice to remove projects that have been deleted. But, I guess that is more an issue with Sublime than this workflow.

 

It would be! And, although that's sort of a Sublime issue, it's also one that that workflow can easily compensate for with a quick call to os.path.exists. See the original download link, or Alleyoop, for an update.

Share this post


Link to post

I'm afraid that's an issue with Sublime. It also doesn't restore open tabs, as far as I know, if you simply double-click the .sublime-project file on your hard drive. Opening the .sublime-workspace file would work—something that I wasn't aware of till just now!—but the subl command doesn't know how to deal with workspaces and they're not bound to open with Sublime in OS X. You'd have to take either of the latter issues up with jps, I think.

 

`subl` can work fine with `.sublime-workspace`. I tried to run `subl project.sublime-workspace` in Terminal, Sublime Text did what I expected.

Share this post


Link to post

Hi,

 

I just updated the workflow. It does not show deleted projects anymore. Thanks!

 

But, to get it to work with my Sublime Text 3 install instead of the Sublime Text 2 install, I had to edit the workflow. You can get it here:

 

https://www.dropbox.com/s/oqmixhnr9j79b2j/Open%20in%20Sublime.alfredworkflow

 

Maybe you can see what I am doing wrong that makes each of your updates only open Sublime Text 2. Since I run both, it would be nice to have a switch for which Sublime to use in the workflow. Some packages I like still only run in Sublime Text 2. There could be a sublime setup keyword for setting which install of Sublime to use, save that to a data file, and use it in all the other scripts. Then you would not have to test each time as well. Just a thought!

Share this post


Link to post

`subl` can work fine with `.sublime-workspace`. I tried to run `subl project.sublime-workspace` in Terminal, Sublime Text did what I expected.

Well I'm just learning new things all over. I'll look into implementing this, then.

 

 

Hi,

 

I just updated the workflow. It does not show deleted projects anymore. Thanks!

 

But, to get it to work with my Sublime Text 3 install instead of the Sublime Text 2 install, I had to edit the workflow. You can get it here:

 

https://www.dropbox.com/s/oqmixhnr9j79b2j/Open%20in%20Sublime.alfredworkflow

 

Maybe you can see what I am doing wrong that makes each of your updates only open Sublime Text 2. Since I run both, it would be nice to have a switch for which Sublime to use in the workflow. Some packages I like still only run in Sublime Text 2. There could be a sublime setup keyword for setting which install of Sublime to use, save that to a data file, and use it in all the other scripts. Then you would not have to test each time as well. Just a thought!

It looks like you've installed ST3 to /Applications/Sublime Text 3.app, whereas by default it installs to /Applications/Sublime Text.app. Although that's a non-standard setup, I can support both by checking for the presence of the ~/Application Support/Sublime Text [n]/ folder rather than the application itself. Since I'm already making changes, I'm also implementing a way to force 2 or 3. Should be posted in just a minute or two.

Share this post


Link to post

That's interesting. Since the first time I installed Sublime Text 3, it has been that way. The first install actually did not have the space before the 3, but I added it for consistency. I did not realize they had dropped the number completely, expect I did notice the title bar no longer has the number.

Share this post


Link to post

Just released: v2.0 of this workflow adds functionality to list projects that have been opened in both ST2 and ST3, and opens the project in the appropriate version without any adjustment on the user's part. It also, thanks to @chrisyipw's pointers, opens .sublime-workspace files, which retain information about opened tabs and all that jazz, rather than .sublime-project files, which do not. It can be downloaded via Alleyoop or at http://alfred.daniel.sh/Workflows/OpenInSublime.alfredworkflow

 

 

That's interesting. Since the first time I installed Sublime Text 3, it has been that way. The first install actually did not have the space before the 3, but I added it for consistency. I did not realize they had dropped the number completely, expect I did notice the title bar no longer has the number.

Maybe you hopped onto an earlier beta build than I did, but I don't remember that. I do recall people being incensed at the dropping of the number, and Jon having some kind of particular reason for it. And I just checked a fresh disk image that has it as plain old unadorned Sublime Text.app. At any rate, the version I just uploaded ought to require less hacking around—though it still uses the paths that I believe to be the default, so you may have to adjust those. (Or switch your Sublime filename.)

Share this post


Link to post

Alright, I'm gonna submit this to the bash scripters out there who are smarter than I—which isn't hard, when it comes to bash scripting. Given a {query} that looks like this:

/Users/danielsh/Dropbox/Writing/Schreber/Schreber.sublime-workspace:::3

…this script is failing to open the workspace correctly:

SUBL_V=`echo -n "{query}" | sed "s/\(.*\)\(:::\)\([23]\)/\3/"`
SUBL_F=`echo -n "{query}" | sed "s/\(.*\)\(:::\)\([23]\)/\1/"`

if [ $SUBL_V -eq 3 ]; then
	/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n --stay "$SUBL_F"
else
	/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl -n --stay "$SUBL_F"
fi

I know the conditional statement is fine, because if I add a notification as output and write something like this, it works:

SUBL_V=`echo -n "{query}" | sed "s/\(.*\)\(:::\)\([23]\)/\3/"`
SUBL_F=`echo -n "{query}" | sed "s/\(.*\)\(:::\)\([23]\)/\1/"`

if [ $SUBL_V -eq 3 ]; then
	echo -n "$SUBL_F"
else
	/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl -n --stay "$SUBL_F"
fi

# Result: notification reading "/Users/danielsh/Dropbox/Writing/Schreber/Schreber.sublime-workspace"

So the problem must be with how I'm invoking Sublime, but I just don't see it. I'm sure it's a schoolboy error of some kind, but I keep missing it. Thoughts, community?

Share this post


Link to post

Just released: v2.0 of this workflow adds functionality to list projects that have been opened in both ST2 and ST3, and opens the project in the appropriate version without any adjustment on the user's part. It also, thanks to @chrisyipw's pointers, opens .sublime-workspace files, which retain information about opened tabs and all that jazz, rather than .sublime-project files, which do not. It can be downloaded via Alleyoop or at http://alfred.daniel.sh/Workflows/OpenInSublime.alfredworkflow

 

 

Maybe you hopped onto an earlier beta build than I did, but I don't remember that. I do recall people being incensed at the dropping of the number, and Jon having some kind of particular reason for it. And I just checked a fresh disk image that has it as plain old unadorned Sublime Text.app. At any rate, the version I just uploaded ought to require less hacking around—though it still uses the paths that I believe to be the default, so you may have to adjust those. (Or switch your Sublime filename.)

 

Hey, your links and main website are dead. It is now some ePublisher. You might want to check it out. 

 

I just got rid of Sublime Text 2 and made my Sublime Text 3 standard. So, I thought I would reload your workflow to remove my changes and I can not get to it. I was able to get the link to your dropbox to work. Since I have all of your workflows, OOP is bombing out. I assume that is due to your site being down as well.

Share this post


Link to post

Thanks for the heads-up! I've been having to do some server migration for a couple of side-projects, and the Alfred stuff kept getting pushed down my list in favor of work stuff. (On top of the fact that learning nginx has been giving me a greasy headache.) Should be back up shortly, though.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...