#!/bin/sh

input=$(grep -Eo "((https?|ftp|git|file|mailto)[.:][^]	 ,;\"'<>\):]*|www\.[-a-z0-9.]+)[^]	 .,;\"'<>\):]" | tac | dmenu -l 10 -i)

if [ $? -eq 0 -a -n "$input" ]; then
  case "$1" in
    "-c")
      echo -n "$input" | xclip
      ;;
    *)
      surf "$input" &
      ;;
  esac
fi

