How to reload Google Chrome tab from terminal?

后端 未结 8 2003
心在旅途
心在旅途 2021-02-02 17:57

Is there a way to reload a Google Chrome tab in Ubuntu using just the terminal. I don\'t want to just open a new window, but to actually refresh a tab!

Extra que

8条回答
  •  庸人自扰
    2021-02-02 18:35

    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 title
    WID=$(xdotool search --onlyvisible --class $BROWSER|head -1)
    #TITLE="window/html file title"
    #WID=$(xdotool search --title "$TITLE"|head -1)
    xdotool windowactivate $WID
    xdotool 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

提交回复
热议问题