vim command + JS snippet for crapshoot livereload
" use in vim
:autocmd BufWritePost * execute "!echo `date` > %.update"<!-- add in webpage -->
<script src="https://www.alexstachowiak.com/livereload.js"></script>-
Serve files using
python -m SimpleHTTPServer 8869 -
Update a file,
"$file.update", on save
:autocmd BufWritePost * execute "!echo `date` > %.update"- Reload webpage when change is detected
/* Also at: https://www.alexstachowiak.com/livereload.js */
<script>
let current = null;
setInterval(() => {
fetch(window.location.href + '.update')
.then(r => r.text())
.then(content => {
if (current == null)
current = content;
else if (current != content)
window.location.href = window.location.href;
})
}, 1000);
</script>Works for index.html, etc., but the save command will need to be updated if the file and URL don't share a name.
