-
Notifications
You must be signed in to change notification settings - Fork 4
/
kantan.sh
executable file
·50 lines (43 loc) · 1.34 KB
/
kantan.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
# Kantan 簡単 (simple, easy) - A set of bash scripts to launch a web server, watch files and launch build commands.
#
# Please take the time to configure the script
#
# The text printed each time you save (probably don't touch this):
FILENAME=$(echo -e "\033[1;33m%w%f\033[0m written")
# The key combination to refresh your browser:
KEY="CTRL+F5"
# The browser you use (currently only firefox is supported):
BROWSER="firefox"
# The folder or file you want to watch:
LOCATION="./demo"
# The server type you want to use (use the ones provided or create your own):
SERVER_TYPE="python"
# The folder you want to serve with the server
DIST="."
# The build command you want to use (ex: npm run dev) or leave empty if you just want to refresh the page:
BUILD=""
case $SERVER_TYPE in
"php")
echo "PHP SERV"
cd $DIST && php -S localhost:8000 index.php & cd ./../ &
;;
"node")
echo "NODE SERV"
node nodeserver.mjs &
;;
"python")
echo "PYTHON SERV"
python3 -m http.server 8000 -d $DIST &
;;
esac
# ./${SERVER_TYPE}server.sh
$BROWSER --new-window http://localhost:8000/
sleep 0.1
WINDOW=$(xdotool search --name ${BROWSER} getactivewindow)
while inotifywait -qre close_write --format "$FILENAME" ${LOCATION}
do
${BUILD}
xdotool windowraise $WINDOW
xdotool key ${KEY}
done