https://github.com/roman-koshchei/live-sh
Live reloading with Bash for any language and any framework
https://github.com/roman-koshchei/live-sh
bash hot-reload javascript language-agnostic live-reload
Last synced: about 2 months ago
JSON representation
Live reloading with Bash for any language and any framework
- Host: GitHub
- URL: https://github.com/roman-koshchei/live-sh
- Owner: roman-koshchei
- License: mit
- Created: 2024-03-08T15:28:27.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-09T08:14:42.000Z (over 2 years ago)
- Last Synced: 2024-12-17T13:09:48.209Z (over 1 year ago)
- Topics: bash, hot-reload, javascript, language-agnostic, live-reload
- Language: Shell
- Homepage: https://github.com/roman-koshchei/live-sh
- Size: 50.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Live shell
```
__ ____ _ _ ____ ___ _ _
( ) (_ _)( \/ )( ___) / __)( )_( )
)(__ _)(_ \ / )__) \__ \ ) _ (
(____)(____) \/ (____)()(___/(_) (_)
```
Live reloading with Bash for any language and any framework
## Get started
Copy [live.sh](./live.sh) into your project directory
```bash
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:
```bash
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](./live.js) into your `head` like this:
```html
document.addEventListener("visibilitychange", function () {
"visible" === document.visibilityState &&
setTimeout(function () {
location.assign(location.href)
}, 250)
})
```