Skip to content

run and re-run any shell script on editor save hooks (instead of fs events, like guard)

Notifications You must be signed in to change notification settings

mweitzel/firetower

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Firetower

Firetower makes it easy to re-run commands while developing.

There are two parts: the firetower command to host a script, and the editor hooks to trigger a restart. These restart the existing firetower in the editor's working directory, so they are usually one liners.

The main script doesn't listen to file system events or anything. It just hosts a command and restarts when requested. Taking advantage of the save hooks offered by most editors make for a much simpler alternative to guard/wachr/grunt-watch/whatever.

In bash. With no dependencies.

Typical Use

  • run firetower "any command" (tests, servers, etc.)
  • relax as it restarts every time you save from an editor in the same working directory

Here's how to install
Here's an example gif

How it works

There are two main operations:

  • -c hosts a new command (assumed when no flag provided)
  • -r restarts an existing firetower

First run a command with firetower

# e.g.
$ firetower "node server.js"
# or
$ firetower "rspec"

Kill it with ctrl-c

Restart it with firetower -r from the same working directory, or with CTR-R in the hosting terminal.

The host creates a temporary file .firetower to store PIDs and assumes your working directory unless you can specify otherwise.

The firetower script is exclusively responsible for running and restarting a command. Again, it does not listen to file system events, so to rerun a script every time you save a file, you should use an editor hook.

Editor hooks

Since the script does not generate any events, we can leverage editor hooks.

To automatically restart a command when you save changes, you can add a hook to the config file of your editor. They utilize events generated by your editor, and call firetower -r for their working directory.

A few existing hooks can be found here.

I primarily use vim and would appreciate pull requests with hooks for other editors!

Options:

usage: firetower [-h | -c | -r | -s] [command] [--directory=directory] [--preserve-scrollback]
  -h help
  -c command - accepts a command to be ran as a string
  -r restart - restarts child process for existing firetower instance
  -s stop    - stops existing firetower instance
  [--directory=directory] specify directory, defaults to current
  [--preserve-scrollback] do not clear terminal on each restart

Installation

  • download firetower, chmod (chmod u+x firetower), and throw into your ~/usr/bin/
  • make sure ~/usr/bin/ is part of your $PATH
  • add an editor hook

PRs welcome!

Example

Here is an example showing a command running on every save:

node hello

License

MIT

About

run and re-run any shell script on editor save hooks (instead of fs events, like guard)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published