Piping fun in shell with fortune and cowsay

Somebody mentioned seashells.io to me. A nifty little service that let’s you pipe output from your shell’s command line directly to the web.

What better use for this than to pipe random funny quotes?


If you want to check out the output – just go here https://seashells.io/v/FCPsK8Sh. It’s running from my shell – so may die any moment.

Show me how!

First, you need to install a couple of packages.

  • cowsay prints an ascii image to the screen, that looks like a cow ( or one of the specified animals).
  • fortune prints a random quote or a “fortune-cookie” type message from a collection of quotes
  • fortune-min is needed on some systems (like Ubuntu), as fortune only comes with the engine, not the db of quotes. Not needed on mac.
  • seashell is a client for seashells.io website. You don’t have to install it, you can just use netstat. It’s up to you. But you do need python & pip available.
sudo apt-get install -y cowsay fortune fortunes-min

# If you are on macOSX, brew is your friend
brew install cowsay fortune 

# if you want seashells client instead of nc
pip install seashells

Now that we have prerequisites, let’s actually use the magic of pipe to combine all the tool togeather!

Note: The choice of animals available to cowsay varies by distribution . For instance, macOSx has blowfish but ubunutu‘s package, doesn’t

If you use fish shell

# Let's wrap some functionality into a handy function
function random_quote
  set animal (random choice {default,dragon,dragon-and-cow,elephant,moose,stegosaurus,tux,vader})
  fortune -s | cowsay -f $animal

# a trick to pipe from loop to another process. Fish only.  
fish -c 'while true; sleep 15; random_quote; end' | nc seashells.io 1337

If you use bash shell

random_quote() {
  choices=("dragon" "dragon-and-cow" "elephant" "moose" "stegosaurus" "tux" "vader")
  animal=${choices[$RANDOM % ${#choices[@]} ]}
  fortune -s | cowsay -f $animal

while true; do sleep 15; random_quote; done | nc seashells.io 1337

How to get rid of .DS_Store on network windows share

If you use Mac with Windows share, you probably were scolded before for leaving ._.DS_Store or .DS_Store files everywhere. They might be invisible to you because you are a demigod using a Mac, but your Windows colleges should be so lucky.

It’s very easy to stop bringing your Mac dirty laundry into a holy Windows house. Just run this command in the Terminal or iTerm and restart your computer

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

To see the current value of of the com.apple.desktopservices DSDontWriteNetworkStores

defaults read com.apple.desktopservices DSDontWriteNetworkStores

If your setting took, it should return 1

Ultimately the solution is to convert all your friends into the cult of Mac