Skip to content

Build & refresh your Asciidoctor projects from Alfred!

Notifications You must be signed in to change notification settings

hacker-DOM/build-refresh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

build-refresh

build-refresh is an Alfred workflow .

Installation

  1. Clone the repository

  2. Double-click on build-refresh.alfredworkflow and import it into Alfred

  3. By default, the workflow uses "Hyper" and "Vivaldi" as the termianl and browser, respectively. If you use different applications, you can change these keywords in the different cells. Each cell has a description that includes info on whether or not it should be changed.

Dependencies

Requires the Alfred Powerpack.

Project setup

You probably want to have a build.sh script. You also want to have a build-open.sh which functions as a fallback in case somebody doesn’t have build-refresh.

build-open.sh

For example, with asciidoctor-pdf, your build-open.sh could look like this:

./build.sh "$@" && \
open *.pdf;

or, for asciidoctor (with html output), you could use:

./build.sh "$@" && \
open *.html;

build-refresh.sh

Finally, you can add a build-refresh.sh that uses this workflow:

# This script requires the Alfred workflow `com.alfredapp.hacker-dom.build-refresh`.
# It can be downloaded from https://github.com/hacker-DOM/build-refresh
# Alfred is a productivity tool for MacOS.
# If you don't have Alfred or this workflow you can just use ./build-open.sh
./build.sh "$@" && \
/usr/bin/osascript -e "tell application \"Alfred 4\" to run trigger \"refresh\" in workflow \"com.alfredapp.hacker-dom.build-refresh\"";

Usage

There are multiple ways to use the workflow:

  1. Anywhere in your operating system, launch Alfred (default Cmd+Space), type build and execute the build trigger of this workflow. The only requirement here is that in your most-recently-used terminal window, the AsciiDoc project is the first tab (more specifically, activatable by Cmd+1).

    This trigger will run ./build-refresh.sh in the first tab of your most-recently-used terminal window.

  2. Alternatively, your can use run build-refresh.sh directly.

Either way, this will run the trigger refresh. This will use Vivaldi’s Api to search its tabs and find one matching one of the following two regexs

/^file:\/\/\/Users\/.*\.pdf$/

/^file:\/\/\/Users\/.*\.html$/

It will then: . activate that tab . activate that window . raise Vivaldi . activate Vivaldi . send Cmd+R to refresh the page 🚀

FAQ

What’s the best way to test, locally, if it is working?

Create an empty directory and add:

  1. a a.adoc file with optional contents,

  2. a build.sh file with asciidoctor-pdf "$@" a.adoc,

  3. a build-refresh.sh as above.

  1. Open a new terminal window and try running build-refresh.sh.

  2. Open a new tab and also a new browser window.

  3. Open a different application, run your Aflred shortcut (default: Cmd+Space), type build, and if a trigger comes up, press Enter. Hyper should be activated, your project built, Vivaldi activated with the right tab and window and the document refreshed - voilà!

For a different-application setup, change the corresponding parts in the workflow, and then in this setup 🙂

Can I use a Safari?

Safari has a different Api and is currently not supported

Something doesn’t work!

Submit an issue! I’d like this workflow to work on all Chromium-browsers, terminals, etc.

About

Build & refresh your Asciidoctor projects from Alfred!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published