Skip to content

Instantly share code, notes, and snippets.

@bgreg
Last active October 26, 2016 18:01
Show Gist options
  • Save bgreg/7c94f7bed56766b04a16597a3bbf3bd4 to your computer and use it in GitHub Desktop.
Save bgreg/7c94f7bed56766b04a16597a3bbf3bd4 to your computer and use it in GitHub Desktop.
Change the color of the iterm tab based on the return value of the last command. RSpec in this case. Good for writing code with fasts tests when you don't want to pay attention to the test window. I Usually use this with a file system watching tool like watchexec. `watchexec --exts js,rb ./bin/spec_runner`
#! /usr/local/bin/zsh
# bin/spec_runner
function color {
case $1 in
green)
echo -e "\033]6;1;bg;red;brightness;57\a"
echo -e "\033]6;1;bg;green;brightness;197\a"
echo -e "\033]6;1;bg;blue;brightness;77\a"
;;
red)
echo -e "\033]6;1;bg;red;brightness;270\a"
echo -e "\033]6;1;bg;green;brightness;60\a"
echo -e "\033]6;1;bg;blue;brightness;83\a"
;;
orange)
echo -e "\033]6;1;bg;red;brightness;227\a"
echo -e "\033]6;1;bg;green;brightness;143\a"
echo -e "\033]6;1;bg;blue;brightness;10\a"
;;
esac
}
rspec spec/
if [ $? -eq 0 ]
then
color green
else
color red
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment