]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/chucknorris/chucknorris.plugin.zsh
b90abe3209265af522f9dd3b05ba5df3a5baf3c8
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / chucknorris / chucknorris.plugin.zsh
1 () {
2   # %x: name of file containing code being executed
3   local fortunes_dir="${${(%):-%x}:h}/fortunes"
4
5   # Aliases
6   alias chuck="fortune -a $fortunes_dir"
7   alias chuck_cow="chuck | cowthink"
8
9   # Automatically generate or update Chuck's compiled fortune data file
10   if [[ "$fortunes_dir/chucknorris" -ot "$fortunes_dir/chucknorris.dat" ]]; then
11     return
12   fi
13
14   # For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
15   local strfile="${commands[strfile]:-/usr/sbin/strfile}"
16   if [[ ! -x "$strfile" ]]; then
17     echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2
18     echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
19     return
20   fi
21
22   # Generate the compiled fortune data file
23   $strfile "$fortunes_dir/chucknorris" "$fortunes_dir/chucknorris.dat" >/dev/null
24 }