about summary refs log tree commit diff stats
path: root/bin/fl
diff options
context:
space:
mode:
Diffstat (limited to 'bin/fl')
-rwxr-xr-xbin/fl30
1 files changed, 18 insertions, 12 deletions
diff --git a/bin/fl b/bin/fl
index bd98a63..cc8924a 100755
--- a/bin/fl
+++ b/bin/fl
@@ -5,28 +5,34 @@
 
 # from pure-sh-bible, strips from the start of a string
 lstrip() {
-	printf '%s\n' "${1##$2}"
+	printf '%s\n' "${1##"$2"}"
 }
 
-# put url-finding regex in a variable so no lines go over 80 chars
-re_urls='((https?://|www\.)[[:alnum:].]*:?[[:alnum:]./@$&%?$#=_-]*)'
+# url-finding regex
+re_urls='(((https?|aesgcm)://|www\.)[[:alnum:].]*:?[[:alnum:]./@$&%?$#=_-]*)'
 
 # finds links, puts them in a list
 # sort -u prevents duplicates, but also sorts the links
 urlparse() {
-	lstrip "$(cat)" "*\│" |
+	input="$(if [ -n "$1" ]; then printf '%s\n' "$*"; else cat; fi)"
+	lstrip "$input" "*\│" |
 	grep -Eo "$re_urls" |
 	sort -u | sed 's|^www.|http://www\.|g'
 }
-if [ -n "$1" ]; then
-	urls=$(echo "$@"|urlparse)
-else
-	urls=$(urlparse)
-fi
+
+set -- $(urlparse "$@")
 
 # wipe IFS so dmenu handles being sent the links properly
 IFS=
 
-# send any found links to dmenu so one can be chosen to be sent to the clipboard
-[ -n "$urls" ] &&
-	echo $urls | dmenu -i -p 'copy which url?' -l 10 | xclip -r -sel c
\ No newline at end of file
+# send any found links to select so one can be chosen to be sent to the clipboard
+#select url;
+#do
+#	printf '%s' "$url"
+#done
+for url; do
+	printf '%s\n' "$url"
+done
+	
+#[ -n "$urls" ] &&
+#	echo $urls | dmenu -i -p 'copy which url?' -l 10 | xclip -r -sel c