]> arthur.barton.de Git - ax-zsh.git/blob - plugins/browser_select/browser_select.zprofile
browser_select: Fix incomplete documentation
[ax-zsh.git] / plugins / browser_select / browser_select.zprofile
1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # browser_select.zprofile: Setup $BROWSER for the "best" available WWW browser
3
4 # Don't run this plugin on "check-plugins"!
5 [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92
6
7 if [[ -z "$BROWSER" ]]; then
8         if [[ "$OSTYPE" != "linux-gnu" ]]; then
9                 # Check for open(1) on Non-Linux systems. On (Debian-) Linux, the open(1)
10                 # command would recursively call $BROWSER (=itself) ...
11                 open_browsers="open"
12         fi
13         if [[ -n "$DISPLAY" ]]; then
14                 # X11 available, consider X11-based browsers, too!
15                 x11_browsers="firefox chrome"
16         fi
17
18         # Note: We can't use xdg-open(1) here, as xdg-open itself tries to use
19         # $BROWSER, and this would result in an endless loop!
20         for browser (
21                 $open_browsers
22                 $x11_browsers
23                 elinks w3m links2 links lynx
24         ); do
25                 if [[ -n "$commands[$browser]" ]]; then
26                         BROWSER="$commands[$browser]"
27                         break
28                 fi
29         done
30         unset browser open_browser x11_browsers
31 fi
32
33 [[ -n "$BROWSER" ]] && export BROWSER