Created
April 11, 2016 15:00
-
-
Save kill9zombie/062b559440e9a72288dec3c586bb4525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rspec_loop --description "Run RSpec in a loop, triggered by file changes" | |
# file: ~/.config/fish/functions/rspec_loop.fish | |
# | |
# Run rspec in a loop. We'll only update the screen when a ruby file | |
# changes. | |
# | |
# usage: rspec_loop 5 | |
# | |
# Where the second argument is the number of seconds to wait | |
# before starting the loop again. Defaults to 10 seconds. | |
# | |
function _files_mtime | |
echo (stat --printf '{%n, %Y}' (find -name '*.rb')) | |
end | |
# Set a sleep default | |
if test -n "$argv" | |
set -g loop_rspec_sleep $argv | |
else | |
set -g loop_rspec_sleep 10 | |
end | |
# Start the main loop | |
while true | |
if test -n (echo $loop_rspec_files) | |
if test $loop_rspec_files != (_files_mtime) | |
clear | |
rspec | |
set -g loop_rspec_files (_files_mtime) | |
end | |
else | |
set -g loop_rspec_files (_files_mtime) | |
clear | |
rspec | |
end | |
sleep (echo $loop_rspec_sleep) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment