scripts

Various scripts for UNIX-like systems
git clone https://git.tronto.net/scripts
Download | Log | Files | Refs | README

dmenu-urlselect (414B)


      1 #!/bin/sh
      2 
      3 # Finds all URLs in stdin and prompts a dmenu choice, then writes the selected
      4 # url to stdout.
      5 # Requires: dmenu (or similar), urlgrep
      6 
      7 # Usage: dmenu-urlselect [-m menu]
      8 
      9 menu="dmenu -i -l 20"
     10 
     11 usage() {
     12 	echo "Usage: dmenu-urlselect [-m MENU]"
     13 }
     14 
     15 while getopts "m:" opt; do
     16 	case "$opt" in
     17 		m)
     18 			menu="$OPTARG"
     19 			;;
     20 		*)
     21 			usage
     22 			exit 1
     23 			;;
     24 		esac
     25 done
     26 shift $((OPTIND - 1))
     27 
     28 urlgrep | $menu