diff --git a/README.md b/README.md index 9c76cbe0..f3e77a8b 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ It may be necessary to logout and login back again to have `pokemonsay` in you ` You can install `pokemonsay` through Homebrew. It is pretty straightforward: ```sh +$ brew install coreutils # to use gshuf $ brew tap possatti/possatti $ brew install pokemonsay ``` diff --git a/pokemonsay.sh b/pokemonsay.sh index 94c6e506..0d6f68cd 100755 --- a/pokemonsay.sh +++ b/pokemonsay.sh @@ -106,13 +106,20 @@ if [ -n "$WORD_WRAP" ]; then word_wrap="-W $WORD_WRAP" fi +# Support MacOS +if [ "$(uname)" == 'Darwin' ]; then + SHUF=gshuf +else + SHUF=shuf +fi + # Define which pokemon should be displayed. if [ -n "$POKEMON_NAME" ]; then pokemon_cow=$(find $pokemon_path -name "$POKEMON_NAME.cow") elif [ -n "$COW_FILE" ]; then pokemon_cow="$COW_FILE" else - pokemon_cow=$(find $pokemon_path -name "*.cow" | shuf -n1) + pokemon_cow=$(find $pokemon_path -name "*.cow" | $SHUF -n1) fi # Get the pokemon name.