-
-
Save Javvadilakshman/3ecc182e1886d812c82f to your computer and use it in GitHub Desktop.
Watches the folder or files passed as arguments to the script and when detects a change it automatically refreshes the current selected Chrome tab or window.
This file contains hidden or 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/bash | |
| # | |
| # Watches the folder or files passed as arguments to the script and when it | |
| # detects a change it automatically refreshes the current selected Chrome tab or | |
| # window. | |
| # | |
| # http://razius.com/articles/auto-refreshing-google-chrome-on-file-changes/ | |
| # | |
| # Usage: | |
| # ./chrome-refresh.sh /folder/to/watch /some/folder/file_to_watch.html | |
| TIME_FORMAT='%F %H:%M' | |
| OUTPUT_FORMAT='%T Event(s): %e fired for file: %w. Refreshing.' | |
| while inotifywait -q -r --timefmt "${TIME_FORMAT}" --format "${OUTPUT_FORMAT}" "$@"; do | |
| CHROME_WINDOW_ID=$(xdotool search --onlyvisible --class google-chrome | head -1) | |
| xdotool key --window $CHROME_WINDOW_ID 'CTRL+r' | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment