build-refresh
is an Alfred workflow .
-
Clone the repository
-
Double-click on
build-refresh.alfredworkflow
and import it into Alfred -
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.
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
.
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;
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\"";
There are multiple ways to use the workflow:
-
Anywhere in your operating system, launch Alfred (default Cmd+Space), type
build
and execute thebuild
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. -
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 🚀
What’s the best way to test, locally, if it is working?
Create an empty directory and add:
-
a
a.adoc
file with optional contents, -
a
build.sh
file withasciidoctor-pdf "$@" a.adoc
, -
a
build-refresh.sh
as above.
-
Open a new terminal window and try running
build-refresh.sh
. -
Open a new tab and also a new browser window.
-
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.