Skip to content

Instantly share code, notes, and snippets.

@razius
Last active November 6, 2018 13:50

Revisions

  1. razius revised this gist Jan 20, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions chrome-refresh.sh
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,8 @@
    # 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

  2. razius created this gist Jan 19, 2014.
    16 changes: 16 additions & 0 deletions chrome-refresh.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/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.
    #
    # 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