Coder Social home page Coder Social logo

deanishe / alfred-sublime-text Goto Github PK

View Code? Open in Web Editor NEW
71.0 3.0 10.0 7.16 MB

Filter and open your Sublime Text (2 and 3) project files from Alfred.

License: MIT License

Shell 2.09% Go 95.03% JavaScript 2.88%
alfred workflow alfred-workflow sublime-text sublime-text-3 project awgo

alfred-sublime-text's Introduction

Sublime Text Projects Alfred Workflow

View, filter and open your Sublime Text (or VSCode) project files.

Download & Installation

Download the workflow from GitHub and install by double-clicking the Sublime-Text-Projects-X.X.X.alfredworkflow file.

Catalina and later

If you're running Catalina or later (macOS 10.15+), you'll need to grant the workflow executable permission to run.

Usage

There is one keyword, .st, which works as follows:

  • .st [<query>] — List/filter your .sublime-project files
    • — Open result in Sublime Text
    • ⌘+↩ — Reveal file in Finder
  • .st rescan — Reload cached list of projects
  • .st config — Show the current settings
    • Workflow Is Up To Date / Workflow Update Available — Install update or check for update
    • Rescan Projects — Reload list of projects
    • Edit Config File — Open workflow's configuration file
    • Editor: Sublime Text / Editor: VS Code — Which editor is selected
    • Action Project File — Whether copying/actioning a search result should use the path of the project file instead of that of the first project directory
    • View Help File — Open README in your browser
    • Report Issue — Open GitHub issue tracker in your browser
    • Visit Forum Thread — Open workflow's thread on alfredforum.com

You can enter search or config as a search query anywhere to jump to the corresponding screen.

Universal Actions

There are Universal Actions for files, URLs and text. Files are opened, and text is inserted into a new document.

Multiple URLs are treated as text, but a single URL is retrieved with curl and a new document is created with its contents.

Hotkeys

The workflow has two Hotkeys (marked red) that you can set to open the currently-selected files in any application in Sublime Text. One Hotkey is for Finder and Path Finder only, and the other is for all other applications. You should set them to the same keyboard shortcut.

The Finder/Path Finder variant doesn't rely on Alfred's "Selection in macOS" feature, and will open the frontmost window's target (the folder whose contents it's showing) if nothing is selected.

External Triggers

The workflow has the following External Triggers that can be used from scripts or other workflows:

Name Description
new Create a new document containing the given text
open Open the specified path in Sublime Text
open-url Create a new document with the data retrieved from URL
search Show project search results for given query

How it works

The workflow scans your system for .sublime-project (or .code-workspace) files using locate, mdfind and (optionally) find. It then caches the list of projects for 10 minutes (by default).

As the locate database isn't enabled on most machines (and isn't updated frequently in any case), and mdfind ignores hidden directories, there is an additional, optional find-based scanner to "fill the gaps", which you must specifically configure (see below).

NOTE: When the workflow is asked to open a directory (e.g. via External Trigger or Universal Action), it looks for a project file in the directory, and opens that instead if one is found.

Configuration

Scan intervals are configured in the workflow's configuration sheet in Alfred Preferences:

Variable Type Usage
INTERVAL_FIND duration How long to cache find search results for
INTERVAL_LOCATE duration How long to cache locate search results for
INTERVAL_MDFIND duration How long to cache mdfind search results for
ACTION_PROJECT_FILE boolean Copying/actioning a search result uses project file path
VSCODE boolean Switch to Visual Studio Code mode

duration values should be of the form 10m or 2h. Set to 0 to disable a particular scanner. boolean values should be of the form true and false or 1 and 0.

The workflow should work "out of the box", but if you have project files in directories that mdfind doesn't see (hidden directories, network shares), you may have to explicitly add some search paths to the sublime.toml configuration file in the workflow's data directory. The file is created on first run, and you can use .st config > Workflow Settings > Edit Config File to open it.

These directories are searched with find.

You can also add glob patterns to the excludes list in the settings file to ignore certain results. Excludes apply to all scanners.

The options are documented in the settings file itself.

Licensing, thanks

All the code is released under the MIT Licence.

The workflow is based on the AwGo workflow library, also released under the MIT Licence.

The icons are based on Font Awesome and Material Design Icons.

alfred-sublime-text's People

Contributors

deanishe avatar dependabot-preview[bot] avatar terminalfi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

alfred-sublime-text's Issues

99% CPU Usage of Python Script

I have no idea why this is happening. But it seems to come from this Alfred Workflow.

It would be massively useful to know how I can get rid of this problem. Because it is rather anoying to have the CPU at 99% and thus the fans running all the time :)

Thanks :)

python__86888_

Only search for project in specified path

I can set custom path ([[path]]) where to look for projects but it seems that it just adds to existing paths rather than replacing them. I would like to have it look only in the path I've specified. Is that possible? Maybe some new option in config to enable that behavior?

Error when trying to open settings.json with `.stconfig`

15:11:34 workflow.py:1265 ERROR    No JSON object could be decoded
Traceback (most recent call last):
  File "/Users/alex/Dropbox/Backups/Alfred.alfredpreferences/workflows/user.workflow.ABD1F06F-0931-42FB-B61F-38DA0C2AF719/workflow/workflow.py", line 1263, in run
    func(self)
  File "sublime.py", line 136, in main
    return do_config(wf)
  File "sublime.py", line 86, in do_config
    dirs = wf.settings.get('search_directories', [])
  File "/Users/alex/Dropbox/Backups/Alfred.alfredpreferences/workflows/user.workflow.ABD1F06F-0931-42FB-B61F-38DA0C2AF719/workflow/workflow.py", line 915, in settings
    self._default_settings)
  File "/Users/alex/Dropbox/Backups/Alfred.alfredpreferences/workflows/user.workflow.ABD1F06F-0931-42FB-B61F-38DA0C2AF719/workflow/workflow.py", line 543, in __init__
    self._load()
  File "/Users/alex/Dropbox/Backups/Alfred.alfredpreferences/workflows/user.workflow.ABD1F06F-0931-42FB-B61F-38DA0C2AF719/workflow/workflow.py", line 554, in _load
    for key, value in json.load(file, encoding='utf-8').items():
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 290, in load
    **kw)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 351, in loads
    return cls(encoding=encoding, **kw).decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 365, 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 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Dependabot can't resolve your Go dependency files

Dependabot can't resolve your Go dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

go: howett.net/[email protected]: unrecognized import path "howett.net/plist" (https fetch: Get https://howett.net/plist?go-get=1: EOF)

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Feature - Expand workflow to include....

Thoughts on expanding this workflows capabilities to include Searching package control and opening the ST Packages folder? If you think it would be useful to combine the two, I will work on your code base and make a PR when ready.

I've got a separate one I made before finding this one that does both of these.

PackageControl searching supports opening up a browser page on the Homepage or Package Control Page

image

image

Support to copy the path of project by Command-C

Currently, I can hold Command to select a project to open it in Finder, it's very convenient.

sometimes I want to quickly copy the folder path into the clipboard,
but when I select a project and press Command-C, it will copy the arguments like this:

(
    "-project",
    "--",
    "/path/to/project/project.sublime-project"
)

Hopes it can support Command+-C to just copy the path of project
to clipboard:

/path/to/project/project.sublime-project

or copy the folder path of project will be better:

/path/to/project

thanks for this awesome workflow,
it helps me a lot.

STConfig workflow change

As I use this everyday, I sometimes run the stconfig rescan command. However it resets to stconfig once do. I think in this change if I ran rescan, it would default back to st so I could immediately search for my projects

Expose chosen result to other workflows

I’ve been trying to figure out a way to call this workflow from my own to do additional actions on the selected project path (e.g: opening a terminal window and cd-ing to the project path, opening the git repo…). Unfortunately even tho I can use a Call External Trigger to do that it will just pass my own inputs to this workflow but without any feedbacks. So this issue is either a call for help or a Feature Request: is it possible to expose the result of the filtering script to other Alfred workflows?

Dependabot can't resolve your Go dependency files

Dependabot can't resolve your Go dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

go: github.com/BurntSushi/[email protected] requires
	github.com/BurntSushi/[email protected] requires
	github.com/BurntSushi/[email protected] requires
	github.com/BurntSushi/[email protected] requires
	github.com/BurntSushi/[email protected] requires
	github.com/BurntSushi/[email protected] requires
	github.com/BurntSushi/[email protected]: invalid version: unknown revision

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Open Already Open Project

Hey,

I just found this Alfred Workflow and it replaced the one I used before.

I have found one thing: right now if you have a project open and use alfred to open it "again" it actually opens up a new Sublime Text window with the project. I would find it ideal if the already open window would open?

Just an idea ;-)

Bad CPU type in executable

Hello,

On my M1 Mac, the workflow is not working. In the debugger I can see the following:

[15:15:19.871] Sublime Text Projects[Script Filter] Queuing argument ''
[15:15:19.940] Sublime Text Projects[Script Filter] Script with argv '' finished
[15:15:19.943] ERROR: Sublime Text Projects[Script Filter] Code 126: /Users/angelo/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/A38ACAF6-4FFB-4D32-99E9-691DBA90A927: line 1: ./alfred-sublime: Bad CPU type in executable

With regards,

Angelo Machils

Folder was moved and renamed, now not being picked up

I moved a folder to a new location and renamed it, but the .st command is not picking it up. The search result still point to the old location. The new location is here:

/Users/rishi/Dropbox (Personal)/Mackup_MacbookPro2017/Sublime-projects/asset-allocation.sublime-project

But the search result in Alfred still only show the old location, which does not even exist anymore:

image

mdfind in terminal finds it fine:

rishi@Rishis-MacBook-Pro-2017:~|⇒  mdfind "asset-allocation"
...
/Users/rishi/Dropbox (Personal)/Mackup_MacbookPro2017/Sublime-projects/asset-allocation.sublime-workspace
/Users/rishi/Dropbox (Personal)/Mackup_MacbookPro2017/Sublime-projects/asset-allocation.sublime-project
...

Any suggestions? Not sure what could be wrong.

Question about behavior

When ST3 is closed and I use alfred-sublime-text, ST3 will open a new window and show the project file for the project I requested (or show the project file in the window of another project). When ST3 is open, ST3 will open the project window I wanted, which is the behavior I want. I suspect this is a function of some ST setting I've bungled. Any idea how to stop the first case? Thank you. Great workflow that I use all the time.

Cannot find projects

I just setup a new computer and followed the instructions for Catalina, the workflow runs but is unable to find projects, I can see them myself in ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/User/Projects. Here’s the log for rescanning:

09:36:56 workflow.go:335: --- Sublime Text Projects/3.1.1 (AwGo/0.20.2) ----
09:36:56 util.go:57: 457.446µs ⧗ load config
09:36:56 main.go:62: &main.options{Search:false, Config:false, Ignore:false, Open:false, OpenProject:false, OpenFolder:false, Rescan:true, Force:true, Query:""}
09:36:56 main.go:64: args=[]string{"-rescan", "-force"} => []string{}
09:36:56 main.go:65: (*main.config)(0xc0000a4480)({
 FindInterval: (time.Duration) 5m0s,
 MDFindInterval: (time.Duration) 5m0s,
 LocateInterval: (time.Duration) 24h0m0s,
 VSCode: (bool) false,
 Excludes: ([]string) <nil>,
 Depth: (int) 2,
 SearchPaths: ([]*main.searchPath) {
 }
})
09:36:56 scan.go:133: [find] reloading ...
09:36:56 scan.go:133: [mdfind] reloading ...
09:36:56 scan.go:133: [locate] reloading ...
09:36:56 scan.go:460: [cache] saved 0 project(s) to sublime-projects-find.txt
09:36:56 scan.go:350: [locate] command failed: <nil>
09:36:56 util.go:57: 5.668752ms ⧗ locate scan
09:36:56 scan.go:460: [cache] saved 0 project(s) to sublime-projects-locate.txt
09:36:56 util.go:57: 248.437604ms ⧗ mdfind scan
09:36:56 scan.go:460: [cache] saved 0 project(s) to sublime-projects-mdfind.txt
09:36:56 scan.go:157: 0 total project(s) found
09:36:56 workflow.go:416: ------------------ 252.191232ms ------------------
[09:36:56.811] Sublime Text Projects[Run Script] Processing complete
[09:36:56.812] Sublime Text Projects[Run Script] Passing output 'Scan complete' to Post Notification

Add ability to search within sublime projects

Hey dean,
I was thinking wouldn't it be cool if alfred-sublime-text had similar file creation options and file opening options as the Sublime-AdvancedNewFile plugin. Meaning that we could do any number of things from the Alfred launch bar:

  1. launch sublime project like normal by hitting enter
  2. tab complete deeper into the project tree and hit enter to open a directory with all files opened just with that directory tree opened in the side bar
  3. keep tab completing to a specific file and hit enter to open that specific file and directory tree (see attached image)
  4. optionally enter text along the way to create a file within the directory tree (this is where it would be like Sublime-AdvancedNewFile)
  5. also in a config file add aliases for different paths (also like Sublime-AdvancedNewFile)

Please see the attached image for a kind of example. What do you think?
feature-request-sublime-alfred-workflow

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.