]> arthur.barton.de Git - ax-zsh.git/blob - plugins/mankier/mankier.zshrc
ls: Add support for "lscolors.sh"
[ax-zsh.git] / plugins / mankier / mankier.zshrc
1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # mankier.zshrc: Setup ManKier online manual page service.
3
4 [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92
5
6 # curl(1) is required to access the online API
7 (( $+commands[curl] )) || return
8
9 explain () {
10         # Explain a shell command. See:
11         # <https://www.mankier.com/blog/explaining-shell-commands-in-the-shell.html>
12
13         local api_url="https://www.mankier.com/api/v2"
14
15         if [[ "$#" -eq 0 ]]; then
16                 while read 'cmd?Explain: '; do
17                         [[ -n "$cmd" ]] || break
18                         curl -Gs "$api_url/explain/?cols=$(tput cols)" --data-urlencode q="$cmd" | less
19                 done
20                 echo "Bye!"
21         else
22                 curl -Gs "$api_url/explain/?cols=$(tput cols)" --data-urlencode q="$*" | less
23         fi
24 }