Skip to content

Latest commit

 

History

History
79 lines (51 loc) · 2.9 KB

readme.md

File metadata and controls

79 lines (51 loc) · 2.9 KB

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