How to reload Google Chrome tab from terminal? How to reload Google Chrome tab from terminal? linux linux

How to reload Google Chrome tab from terminal?


One liner which will focus the Chrome window and then reload the browser by sending Control+r:

xdotool search --onlyvisible --class Chrome windowfocus key ctrl+r


sudo apt-get updatesudo apt-get install xdotoolDISPLAY=:0 xdotool key F5

That's all you need.


Looks like user2974830's answer is using some incorrect (perhaps old) syntax for xdotool. --search is supposed to be just search (without the dashes) and --windowid is supposed to be --window

That being said here's a more comprehensive solution that I found here. The link uses inotifywait, but I prefer entr which wraps inotifywait.

echo "$(date --rfc-3339=seconds) Refresh: $FILE"CUR_WID=$(xdotool getwindowfocus)#gets the first $BROWSER window, if you have more than one#$BROWSER window open, it might not refresh the right one,#as an alternative you can search by the window/html titleWID=$(xdotool search --onlyvisible --class $BROWSER|head -1)#TITLE="window/html file title"#WID=$(xdotool search --title "$TITLE"|head -1)xdotool windowactivate $WIDxdotool key 'ctrl+r'xdotool windowactivate $CUR_WID

I saved it to a file called reload-chrome-nix and I run find . -type f | entr ./reload-chrome-nix