#!/usr/bin/env bash

export PATH="$HOME/bin:$PATH"

iface="$(route get 1.1.1.1 2>/dev/null | grep interface | perl -ple 's/\s*interface:\s*//')"
if [ $? != 0 ]; then
  iface="n/a"
fi

case "$iface" in
  en0)
    menu="🍌 Wi-Fi"
    ;;
  en3|en4|en5)
    menu="🍉 Eth"
    ;;
  utun4)
    menu="🍒 VPN"
    ;;
  *)
    menu="🌽 $iface"
    ;;
esac

echo "$menu"
echo "---"
echo "sindent | shell=$HOME/bin/sindent"
echo "escape quotes | shell=$HOME/bin/escquotes"
echo "unixtime | shell=$HOME/bin/unixtime"
echo "---"
[ -e /tmp/p ] && cat /tmp/p | sed -e 's/$/ | shell=open param1=-a param2=MacVim param3=\/tmp\/p/' || true