plan9port/bin/web

113 lines
1.5 KiB
Text
Raw Normal View History

2004-03-02 23:11:58 +00:00
#!/bin/sh
2005-01-11 19:23:52 +00:00
plumbfirefox()
{
echo '
tell application "Firefox"
activate
tell application "System Events"
tell process "firefox"
keystroke "t" using {command down}
end tell
end tell
Get URL "'$1'"
end tell
' | osascript
}
plumbsafari()
{
echo '
tell application "Safari"
activate
tell application "System Events"
tell process "safari"
keystroke "t" using {command down}
end tell
end tell
open location "'$1'"
end tell
' | osascript
}
plumbapple()
2004-03-02 23:11:58 +00:00
{
2005-01-11 19:23:52 +00:00
case ${BROWSER:-none} in
firefox)
plumbfirefox "$@"
;;
safari)
plumbsafari "$@"
;;
none)
if [ -d /Applications/Firefox.app ]
then
plumbfirefox "$@"
else
plumbsafari "$@"
fi
;;
esac
}
plumbunix()
{
2005-05-07 22:32:03 +00:00
case "${BROWSER:=firefox}" in
2004-03-02 23:11:58 +00:00
# Other browsers here
# ...
*opera*)
2006-06-25 23:49:10 +00:00
$BROWSER -remote 'openURL('"$@"',new-page)'
2004-03-02 23:11:58 +00:00
;;
*firebird*)
2006-06-25 23:49:10 +00:00
$BROWSER -remote 'openURL('"$@"',new-window)'
2004-03-25 23:03:22 +00:00
;;
2004-03-21 04:32:36 +00:00
*firefox*)
2006-06-25 23:49:10 +00:00
$BROWSER -remote 'openURL('"$@"',new-tab)' ||
$BROWSER "$@"
2004-03-02 23:11:58 +00:00
;;
2004-07-03 17:46:40 +00:00
*mozilla*)
2006-06-25 23:49:10 +00:00
$BROWSER -remote 'openURL('"$@"',new-tab)' ||
$BROWSER "$@"
2004-07-03 17:46:40 +00:00
;;
2004-03-02 23:11:58 +00:00
esac
}
2005-01-11 19:23:52 +00:00
plumb1()
{
case `uname` in
Darwin)
plumbapple "$@"
;;
*)
plumbunix "$@"
;;
esac
}
2004-03-02 23:11:58 +00:00
if [ $# = 0 ]
then
plumb1 about:blank
else
2006-06-25 23:49:10 +00:00
for i in "$@"
2004-03-02 23:11:58 +00:00
do
if [ -f "$i" ]
then
2006-06-25 23:49:10 +00:00
p=`pwd | sed 's/ /%20/g'`
2005-05-07 22:32:03 +00:00
i=`echo $i | sed 's/ /%20/g'`
2006-06-25 23:49:10 +00:00
i=`cleanname -d "$p" "$i"`
2004-06-09 14:05:29 +00:00
i=file://$i
2005-05-07 22:32:03 +00:00
else
i=`echo $i | tr -d ' '`
2004-03-02 23:11:58 +00:00
fi
2006-06-25 23:49:10 +00:00
echo p "$i"
2004-03-02 23:11:58 +00:00
plumb1 $i
done
fi
case $BROWSER in
*opera*)
$BROWSER -remote 'raise()'
esac