Blame view

plugins/chucknorris/chucknorris.plugin.zsh 976 Bytes
ed37aae5b   mj   Squashed 'repos/r...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  # chucknorris: Chuck Norris fortunes
  
  # Automatically generate or update Chuck's compiled fortune data file
  # $0 must be used outside a local function. This variable name is unlikly to collide.
  CHUCKNORRIS_PLUGIN_DIR=${0:h}
  
  () {
  local DIR=$CHUCKNORRIS_PLUGIN_DIR/fortunes
  if [[ ! -f $DIR/chucknorris.dat ]] || [[ $DIR/chucknorris.dat -ot $DIR/chucknorris ]]; then
    # For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
    local strfile=strfile
    if ! which strfile &>/dev/null && [[ -f /usr/sbin/strfile ]]; then
      strfile=/usr/sbin/strfile
    fi
    if which $strfile &> /dev/null; then
      $strfile $DIR/chucknorris $DIR/chucknorris.dat >/dev/null
    else
      echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2
      echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
    fi
56a5793ce   mj   Squashed 'repos/r...
21
  fi
ed37aae5b   mj   Squashed 'repos/r...
22
23
  # Aliases
  alias chuck="fortune -a $DIR"
56a5793ce   mj   Squashed 'repos/r...
24
  alias chuck_cow="chuck | cowthink"
ed37aae5b   mj   Squashed 'repos/r...
25
26
27
  }
  
  unset CHUCKNORRIS_PLUGIN_DIR