scripts

My personal collection of scripts
git clone git://src.gearsix.net/scripts
Log | Files | Refs | Atom | README | LICENSE

openurl.sh (452B)


      1 #!/bin/sh
      2 # openurl
      3 # description: xdg-open all urls found in $@
      4 # e.g.$ openurl saved-links.txt
      5 
      6 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
      7 	echo "usage: ./openurl.sh FILEPATHS..."
      8 	echo ""
      9 	echo "open all links existing in contents of listed files"
     10 	exit
     11 fi
     12 
     13 for f in "$@"; do
     14 	while read -r url; do
     15 		cmd=$(open "$url" | grep -q 'https?://(^")+' | tr -d '\r')
     16 		if [ "$(uname)" != "Darwin" ]; then cmd="xdg-"+$cmd; fi
     17 		$cmd
     18 	done < "$f"
     19 done
     20