]> arthur.barton.de Git - ax-zsh.git/blob - plugins/browser_select/browser_select.zprofile
New "browser_select" plugin
[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
8 if [[ -z "$BROWSER" ]]; then
9         if [[ -n "$DISPLAY" ]]; then
10                 # X11 available, consider X11-based browsers, too!
11                 x11_browsers="firefox chrome"
12         fi
13
14         # Note: We can't use xdg-open(1) here, as xdg-open itself tries to use
15         # $BROWSER, and this would result in an endless loop!
16         for browser (
17                 open
18                 $x11_browsers
19                 elinks w3m links2 links lynx
20         ); do
21                 if [ -n "$commands[$browser]" ]; then
22                         BROWSER="$commands[$browser]"
23                         break
24                 fi
25         done
26         unset browser x11_browsers
27 fi
28
29 [[ -n "$BROWSER" ]] && export BROWSER