X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-web--browse.sh;h=384148a59fc492d8fb1d6ea4fc4532aa1e5ffc22;hb=2c47789d817aaf745a5ce5d5f79619c634cc8566;hp=3ade500e0c4bcdbd06809f3b4e03d087498bd3b7;hpb=193ad4f63c511948050079ddbe8c9b7342bf85a4;p=git.git diff --git a/git-web--browse.sh b/git-web--browse.sh index 3ade500e0..384148a59 100755 --- a/git-web--browse.sh +++ b/git-web--browse.sh @@ -23,18 +23,24 @@ USAGE='[--browser=browser|--tool=browser] [--config=conf.var] url/file ...' NONGIT_OK=Yes . git-sh-setup +valid_custom_tool() +{ + browser_cmd="$(git config "browser.$1.cmd")" + test -n "$browser_cmd" +} + valid_tool() { case "$1" in - firefox | iceweasel | konqueror | w3m | links | lynx | dillo) + firefox | iceweasel | konqueror | w3m | links | lynx | dillo | open) ;; # happy *) - return 1 + valid_custom_tool "$1" || return 1 ;; esac } init_browser_path() { - browser_path=$(git "config browser.$1.path") + browser_path=$(git config "browser.$1.path") test -z "$browser_path" && browser_path="$1" } @@ -104,6 +110,10 @@ if test -z "$browser" ; then else browser_candidates="w3m links lynx" fi + # SECURITYSESSIONID indicates an OS X GUI login session + if test -n "$SECURITYSESSIONID"; then + browser_candidates="open $browser_candidates" + fi for i in $browser_candidates; do init_browser_path $i @@ -118,7 +128,7 @@ else init_browser_path "$browser" - if ! type "$browser_path" > /dev/null 2>&1; then + if test -z "$browser_cmd" && ! type "$browser_path" > /dev/null 2>&1; then die "The browser $browser is not available as '$browser_path'." fi fi @@ -147,10 +157,15 @@ case "$browser" in ;; esac ;; - w3m|links|lynx) + w3m|links|lynx|open) eval "$browser_path" "$@" ;; dillo) "$browser_path" "$@" & ;; + *) + if test -n "$browser_cmd"; then + ( eval $browser_cmd "$@" ) + fi + ;; esac