Firefox refresh current tab from command-line
Here's an updated version of @geekQ's script that will return focus to the previous program (however, the firefox window will still be pulled to the top).
#!/bin/bash
CURRENT_WID=$(xdotool getwindowfocus)
WID=$(xdotool search --name "Mozilla Firefox")
xdotool windowactivate $WID
xdotool key F5
xdotool windowactivate $CURRENT_WID
For OS X you can do it with these few lines of applescript:
activate application "Firefox"
tell application "System Events" to keystroke "r" using command down
You can use xdotool for automation. Install on Ubuntu with
sudo aptitude install xdotool
Then you can search for windows and send keys or mouse events, see man xdotool
for the full documentation. I use following script on Ubuntu 16.04 LTS during development:
WID=`xdotool search --name "Mozilla Firefox" | head -1`
xdotool windowactivate $WID
xdotool key F5
Note: in the older versions, e.g. Ubuntu 14.04 the flag is --title
instead of --name
.
See also the xdotool project site.