blob: 10f59dd713ed4b1e40cbd8484af4545a2d6821bd [file] [log] [blame]
rscaf78a4c2004-03-02 23:11:58 +00001#!/bin/sh
2
rsc5645c4a2005-01-11 19:23:52 +00003plumbfirefox()
rscaf78a4c2004-03-02 23:11:58 +00004{
rsc5645c4a2005-01-11 19:23:52 +00005 echo '
6 tell application "Firefox"
7 activate
8 tell application "System Events"
9 tell process "firefox"
10 keystroke "t" using {command down}
11 end tell
12 end tell
13 Get URL "'$1'"
14 end tell
15 ' | osascript
16}
17
18plumbsafari()
19{
20 echo '
21 tell application "Safari"
22 activate
23 tell application "System Events"
24 tell process "safari"
25 keystroke "t" using {command down}
26 end tell
27 end tell
28 open location "'$1'"
29 end tell
30 ' | osascript
31}
32
Russ Cox6c998702008-10-08 14:58:14 -070033plumbcamino()
34{
35 echo '
36 tell application "Camino"
37 activate
38 tell application "System Events"
39 tell process "camino"
40 keystroke "t" using {command down}
41 end tell
42 end tell
43 Get URL "'$1'"
44 end tell
45 ' | osascript
46}
47
rsc5645c4a2005-01-11 19:23:52 +000048plumbapple()
49{
50 case ${BROWSER:-none} in
51 firefox)
52 plumbfirefox "$@"
53 ;;
54 safari)
55 plumbsafari "$@"
56 ;;
Russ Cox6c998702008-10-08 14:58:14 -070057 camino)
58 plumbcamino "$@"
59 ;;
rsc5645c4a2005-01-11 19:23:52 +000060 none)
Russ Cox6c998702008-10-08 14:58:14 -070061 if [ -d /Applications/Camino.app ]
62 then
63 plumbcamino "$@"
64 elif [ -d /Applications/Firefox.app ]
rsc5645c4a2005-01-11 19:23:52 +000065 then
66 plumbfirefox "$@"
67 else
68 plumbsafari "$@"
69 fi
70 ;;
71 esac
72}
73
74plumbunix()
75{
rsc0156f052005-05-07 22:32:03 +000076 case "${BROWSER:=firefox}" in
rscaf78a4c2004-03-02 23:11:58 +000077 # Other browsers here
78 # ...
79 *opera*)
rsc27909142006-06-25 23:49:10 +000080 $BROWSER -remote 'openURL('"$@"',new-page)'
rscaf78a4c2004-03-02 23:11:58 +000081 ;;
82 *firebird*)
rsc27909142006-06-25 23:49:10 +000083 $BROWSER -remote 'openURL('"$@"',new-window)'
rsccb274432004-03-25 23:03:22 +000084 ;;
rsca770daa2004-03-21 04:32:36 +000085 *firefox*)
rsc27909142006-06-25 23:49:10 +000086 $BROWSER -remote 'openURL('"$@"',new-tab)' ||
87 $BROWSER "$@"
rscaf78a4c2004-03-02 23:11:58 +000088 ;;
wkj71be0912004-07-03 17:46:40 +000089 *mozilla*)
rsc27909142006-06-25 23:49:10 +000090 $BROWSER -remote 'openURL('"$@"',new-tab)' ||
91 $BROWSER "$@"
wkj71be0912004-07-03 17:46:40 +000092 ;;
rscaf78a4c2004-03-02 23:11:58 +000093 esac
94}
95
rsc5645c4a2005-01-11 19:23:52 +000096plumb1()
97{
98 case `uname` in
99 Darwin)
100 plumbapple "$@"
101 ;;
102 *)
103 plumbunix "$@"
104 ;;
105 esac
106}
107
108
rscaf78a4c2004-03-02 23:11:58 +0000109if [ $# = 0 ]
110then
111 plumb1 about:blank
112else
rsc27909142006-06-25 23:49:10 +0000113 for i in "$@"
rscaf78a4c2004-03-02 23:11:58 +0000114 do
115 if [ -f "$i" ]
116 then
rsc27909142006-06-25 23:49:10 +0000117 p=`pwd | sed 's/ /%20/g'`
rsc0156f052005-05-07 22:32:03 +0000118 i=`echo $i | sed 's/ /%20/g'`
rsc27909142006-06-25 23:49:10 +0000119 i=`cleanname -d "$p" "$i"`
rsc4c2a6582004-06-09 14:05:29 +0000120 i=file://$i
rsc0156f052005-05-07 22:32:03 +0000121 else
122 i=`echo $i | tr -d ' '`
rscaf78a4c2004-03-02 23:11:58 +0000123 fi
rsc27909142006-06-25 23:49:10 +0000124 echo p "$i"
rscaf78a4c2004-03-02 23:11:58 +0000125 plumb1 $i
126 done
127fi
128
129case $BROWSER in
130*opera*)
131 $BROWSER -remote 'raise()'
132esac
133