commit 5870d5b03967cb765b14ece15e5a488d58d419a0
parent 88179913d3535ad42c45c38927807f5ff7d37971
Author: gearsix <gearsix@tuta.io>
Date: Thu, 11 Nov 2021 11:16:05 +0000
re-wrote openurl to be more simple
Diffstat:
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
@@ -65,7 +65,7 @@ Useful for debugging somebody else's code in a terminal.
- *backup* - cp input files $@ from `filename` to `filename.bak` (mv with `-m`)
- *catrm* `rm -i` but with the option to cat the file
- *flac2mp3* - converts .flac files $@ to .mp3. Requires ffmpeg.
-- *openurl* - open a .url file $1 (see http://www.danielbrice.net/blog/opening-url-file-like-a-pro/)
+- *openurl* - xdg-open all links found in files $@
- *mkdcp* - make directory $1 and copy files into it ($2..$n)
- *mkdmv* - make directory $1 and move files into it ($2..$n)
- *mkdnvim* - make directory $1, touch file $2 and open file $2 in nvim
diff --git a/src/depreciated/openurl.sh b/src/depreciated/openurl.sh
@@ -0,0 +1,13 @@
+# DEPRECIATED: found a more simple solution (see new opeurl.sh)
+
+#!/bin/sh
+# openurl
+# description: script for opening .url filetype
+# e.g.$ openurl link.url
+# SEE: http://www.danielbrice.net/blog/opening-url-file-like-a-pro/
+# NOTE: see http://www.danielbrice.net/blog/opening-url-file-like-a-pro/ for .url spec
+
+URL=$(cat "$1" | grep "URL=" | cut -d= -f2)
+echo -e "xdg-open $URL"
+xdg-open "$URL" &> /dev/null
+
diff --git a/src/openurl.sh b/src/openurl.sh
@@ -1,11 +1,10 @@
#!/bin/sh
# openurl
-# description: script for opening .url filetype
-# e.g.$ openurl link.url
-# SEE: http://www.danielbrice.net/blog/opening-url-file-like-a-pro/
-# NOTE: see http://www.danielbrice.net/blog/opening-url-file-like-a-pro/ for .url spec
-
-URL=$(cat "$1" | grep "URL=" | cut -d= -f2)
-echo -e "xdg-open $URL"
-xdg-open "$URL" &> /dev/null
+# description: xdg-open all urls found in $@
+# e.g.$ openurl saved-links.txt
+for f in $@; do
+ for url in "$(grep -o -E 'https?://[^"]+' $f)"; do
+ xdg-open "$ur3l";
+ done
+done