roman-koshchei / live-sh

Live reloading with Bash for any language and any framework

Home Page:https://github.com/roman-koshchei/live-sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Live shell

 __    ____  _  _  ____    ___  _   _
(  )  (_  _)( \/ )( ___)  / __)( )_( )
 )(__  _)(_  \  /  )__)   \__ \ ) _ (
(____)(____)  \/  (____)()(___/(_) (_)

Live reloading with Bash for any language and any framework

Get started

Copy live.sh into your project directory

curl -o live.sh https://raw.githubusercontent.com/roman-koshchei/live-sh/main/live.sh

Change instructions inside of run function. Notice long running process should be run in background and saved to previous_pid. Here is example to run Gleam project, where gleam run is long running process:

run() {
  gleam run &
  previous_pid=$!
  gleam format &
}

Run script with ./live.sh. If you are on Windows then use Git Bash or WSL.

Browser reloading

If you are building web app you may want to automatically reload browser tab after live reloading project. For it you need to add javascript script to your site, don't forget to disable it in production.

Just embed live.js into your head like this:

<head>
  <script>
    document.addEventListener("visibilitychange", function () {
      "visible" === document.visibilityState &&
        setTimeout(function () {
          location.assign(location.href)
        }, 250)
    })
  </script>
</head>

About

Live reloading with Bash for any language and any framework

https://github.com/roman-koshchei/live-sh

License:MIT License


Languages

Language:Shell 79.8%Language:JavaScript 20.2%