bin/scripts/reload-browser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh # reload-browser - A cross-platform wrapper for reloading the current # browser tab # Eric Radman, 2014 # http://eradman.com/entrproject/scripts/ usage() { case `uname` in Darwin) # applescript needs the exact title echo "Usage: $(basename $0) Firefox [Safari \"Google Chrome\" ...]" ;; *) # xdotool uses regular expressions echo "Usage: $(basename $0) Firefox [Chrome ...]" ;; esac exit 1 } [ $# -lt 1 ] && usage active=$(xdotool getactivewindow) for app in "$@" do case `uname` in Darwin) /usr/bin/osascript <<-APPLESCRIPT set prev to (path to frontmost application as text) tell application "$app" activate end tell delay 0.5 tell application "System Events" to keystroke "r" using {command down} delay 0.5 activate application prev APPLESCRIPT ;; *) xdotool search --onlyvisible --class "$app" windowfocus key \ --window %@ 'ctrl+r' || { 1>&2 echo "unable to signal an application named \"$app\"" } xdotool windowfocus --sync ${active} ;; esac done