alfred-sublime-text

command module
v0.0.0-...-791c2df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2021 License: MIT Imports: 21 Imported by: 0

README

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.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL