Skip to content

Instantly share code, notes, and snippets.

@temp3l
Last active December 20, 2016 22:26
Show Gist options
  • Save temp3l/e9cc06258f07462bb658580d888d9fd0 to your computer and use it in GitHub Desktop.
Save temp3l/e9cc06258f07462bb658580d888d9fd0 to your computer and use it in GitHub Desktop.
sync esp8266 files on change
#!/bin/bash -xe
nmcut="node ../node_modules/nodemcu-tool/bin/nodemcu-tool.js"
terminal="xfce4-terminal --geometry=120x20+300+200"
$terminal -e "$nmcut --connection-delay 200 terminal </dev/null &>/dev/null &"
killSessions ()
{
pid=$(ps fax | grep nodemcu-tool | grep terminal|awk -F " " '{print $1}' )
echo "PID was: $pid"
if [ ! -z "$pid" ]; then
echo "killing"
kill $pid;
fi
}
inotifywait -mq -e close_write --format %w%f *.lua | while read FILE
do
killSessions
sleep 1
nodemcu-tool upload $FILE
if [ "$FILE" = "init.lua" ]; then
sleep 1
nodemcu-tool reset
fi
$terminal -e "$nmcut --connection-delay 200 terminal </dev/null &>/dev/null &"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment