Created
March 5, 2013 04:43
-
-
Save Dubhead/5088076 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh -x | |
# ファイルに変更があったらブラウザを自動リロードする。 | |
# ブラウザ側に拡張などを入れる必要なし。 | |
# 要: inotifywait, xdotool | |
# 参考: http://stackoverflow.com/questions/4680109/how-to-reload-refresh-a-web-page-without-leaving-my-web-development-ide/10739606#10739606 | |
# 参考: http://unix.stackexchange.com/questions/37258/refresh-reload-active-browser-tab-from-command-line/42933#42933 | |
RELOAD_KEYS="CTRL+R" | |
# RELOAD_KEYS="SHIFT+CTRL+R" | |
DEFAULT_BROWSER="Mozilla Firefox" | |
BROWSER=$1 | |
if [ -z "${BROWSER}" ]; then | |
BROWSER=$DEFAULT_BROWSER | |
fi | |
while true; do | |
inotifywait -qq --recursive --event modify ./ | |
MYWINDOW=$(xdotool getactivewindow) | |
xdotool search --name ${BROWSER} windowactivate --sync | |
xdotool search --name ${BROWSER} key --clearmodifiers ${RELOAD_KEYS} | |
xdotool windowfocus --sync ${MYWINDOW} | |
xdotool windowactivate --sync ${MYWINDOW} | |
done | |
# eof vim:set syntax=zsh: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment